Practical Regex Building: The Regex to Match the Files part of a Unix-Like Command (ls)

This post is part of a practical series on regex (regular expressions) in a bash shell. Setup Let’s make a shell script. In your favourite editor type #!/bin/bash And save it somewhere as test.sh. Now we need to make it executable as follows: [ahmed@amayem ~]$ chmod +x ./testt.sh [ahmed@amayem ~]$ ./test.sh Looks good so far.…

Practical Regex Building: The Regex to Match the Options part of a Unix-Like Command (ls)

This post is part of a practical series on regex (regular expressions) in a bash shell. Setup Let’s make a shell script. In your favourite editor type #!/bin/bash And save it somewhere as test.sh. Now we need to make it executable as follows: [ahmed@amayem ~]$ chmod +x ./testt.sh [ahmed@amayem ~]$ ./test.sh Looks good so far.…

Practical Regex Building: Emulating the ls Command to Separate Options from Files

The best way to learn how to use regex (regular expressions) is to use it practically. This will be a series of educational posts that shows how to go about making regular expressions iteratively by starting small then building up. Goal When making your own shell command, you may want to emulate the format of…

ShellTree 6: Further Optimization by Removing Changes to IFS

This post is part of an educational series on building a shell script to graphically display the structure of a directory. Previously We broke down Dem Pilafian’s one line command to display a tree of a directory We broke down Dem Pilafian’s script that uses the one line command We modified the one line to…

Bash: Passing Whitespace as Parameters to Functions

This post will deal with how to pass whitespace as a parameter to a function in bash shell scripting. Pre-requisites Understanding bash whitespace quotation and backslash escaped characters Understanding IFS and how to modify it and its effects Setup Let’s make a shell script. In your favourite editor type #!/bin/bash And save it somewhere as…