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…