...

/

Globbing and Quoting

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.

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:

Press + to interact
touch file1 file2 file3
ls *
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 to echo

Type all the commands in this lesson out in the terminal below.

Terminal 1
Terminal
Loading...

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 ...

Access this course and 1400+ top-rated courses and projects.