User Tools

Site Tools


Special Characters

Special characters, also called metacharacters, are a group of characters that have particular meanings in the bash language.
Listed here are those used in the following scripts. Type the examples and try to get the meaning.

* a string with o or more character

   ls /dev/tty*

? a single character

   ls /dev/tty?

[ ] one of a single character listed

   ls /dev/tty[2-4]

{} one of a single string listed

   ls /dev/tty{zd,zc}

More information on Regular expression metacharacters can be found here


You can prevent the shell from interpreting a metacharacter by placing a backslash ().
In this way the metacharacter become a normal character.

cp file1 file\?

file1 will be copied to file? You can also insert the metacharacter between quotation marks.

   ls /dev/"tt*"

Compare the difference

   ls /dev/tt*
wiki/metacharacters.txt · Last modified: 2021/01/20 20:36 (external edit)