Examples of using wildcard characters

1. To match any number of characters in a filename:

   ls *.txt

This lists all the files in the current directory that have the extension .txt. So Help.txt as well as nonsense.txt would be listed.

2. To match any single character in a filename:

   cat memo? > mymemos

This concatenates all files with the filename

   memo0 -> memo9
   memoa -> memoz
   memoA -> memoZ

and places their contents in the file mymemos.

3. To remove a range of files:

   rm part[1-3]

This removes files part1, part2 and part3 from the current directory. If no files are found that match these names the message

   No match

is displayed.

4. To look for an expression in a file:

   grep '[Jj]ohn' < addresses

This looks for and, if found, displays the lines containing the name john or John in the file addresses.

Notice that the expression to be searched for is enclosed in 'quotes' to prevent the '[' character being interpreted by the shell.

Top document