Ahmed Amayem has written 90 articles

A Web Application Developer Entrepreneur.

Solving the Mystery of the Regular Expression Special Operator Star * Not Matching Anything (Matching the Null String)

When using regular expressions the * special operator is very useful. An expression followed by * matches a sequence of 0 or more matches of the expression. When the whole expression is followed by a * we get some intersting behaviour that people may not have expected. We will explore such behaviour in this post.…

Four Ways to Quickly Create Files from Command Line on Unix-Like Systems (bash)

Quickly creating files in Unix-like systems from command line is pretty easy. Here are four ways to do it. Method 1: touch filename Just use the touch command followed by the filename: [ahmed@amayem ~] touch filename [ahmed@amayem ~] ls filename Method 2: > filename This is probably the easiest way: [ahmed@amayem ~] ls [ahmed@amayem ~]…

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…