4.1. Using the *

Use the asterisk to match any part of a filename. Here we specify app*, which means list all filenames that have ‘app’ at the beginning of the filename and anything else after that:

						$ ls app* 
appdva          app_tapes 
appdva_SLA
					

Use the asterisk to match at the beginning of the string. Here we list all documents that end with ‘.doc’:

						$ ls *.doc 
accounts.doc    qtr_end.doc
					

You can also use the asterisk during any part of filenames you want to match. Here we say match the filenames beginning with ‘cl’, and any other characters after that, but they must end with .sed.

						$ ls cl*.sed 
cleanmeup.sed        cleanlogs.sed 
cleanmessages.sed
					

Use the asterisk to save yourself from typing in the full directory name when you want to cd into that directory: ...

Get Linux and Unix Shell Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.