O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required