|
Forum Index : Microcontroller and PC projects : UNIX-like commands: cat dir grep more
| Author | Message | ||||
| rave Newbie Joined: 24/02/2018 Location: United StatesPosts: 28 |
Hi all, I've uploaded my UNIX-like "implied RUN commands" to FruitOfTheShed These commands are: cat catenate files to output dir list files grep search files using a pattern or string more file pager and hexdump utility These commands support the following useful command-line features: - File and directory name globbing with * and ? - Paths can be separated with \ as usual or with / - Input can be redirected with < FILE - Output can be redirected with > FILE or >> FILE (append) This works thanks to the power of MMBasic 4.5. Geoff did a great job and for MMBasic.For example: - Display and page through all .bas files in the project directory and its subdirectories (hit key SPACE/ENTER/ESC while viewing): more project/*.bas project/*/*.bas - Hexdump all .bmp files located in B:\images: more -x B:\images\*.bmp - Search and display the lines with line numbers of .bas files in the project directory that have the text "Usage" at the start of the line: grep -n "^Usage:" project/*.bas A driver program WALKDIRS.BAS is included in MMUNIX-v2.zip to implement your own UNIX-like commands. The driver program performs de-globbing and sets up file redirects. This way you only have to add a few command-related subs to perform actions on files/directories .I've "stolen" a bit of beautiful code written by Rob Pike for regex matching with my grep implementation, but I rewrote it in MMBasic and added the [] ? + operators to make it more useful. Enjoy! - Rob |
||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1671 |
Hi Rob! Congratulation! Good job! GREP and REGEX are a must have. I will try later. Kind regards Michael causality ≠ correlation ≠ coincidence |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |