Globbing and Quoting
This lesson will introduce you to the joy of quoting in bash. You will learn what globbing is and what its special characters are. It’ll also explain the difference between single and double quotes, and you’ll learn the difference between globs and regular expressions.
We'll cover the following...
If you’ve come across it before, you may have wondered what the *
in bash commands really means, and how it is different from regular expressions.
Note: Do not panic if you don’t know what regular expressions are. Regular expressions are patterns used to search for matching strings. Globs look similar and perform a similar function, but are not the same. That’s the key point to understand about globs vs regular expressions.
How Important is this Lesson?
Globbing and quoting are essential topics when using bash. It’s rare to come across a set of commands or a script that doesn’t depend on knowledge of them.
Globbing
Type these commands into the terminal:
touch file1 file2 file3ls *echo *
-
Line 1 creates three files (
file1
,file2
,file3
) -
Line 2 runs the
ls
command, asking to list the files matching*
-
Line 3 runs the
echo
command using*
as the argument toecho
Type all the commands in this lesson out in the terminal below.
Note: continue to use this terminal during this lesson. Throughout this course it is assumed that you complete each lesson by typing in the commands in the provided terminal for that lesson in the order the commands are given.
You should be able to see the three files listed when both, line 4 and line 5, are executed.
The ...