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.2. Using the ?

Use the ? to match any single character. Here we list filenames where the first two characters can be any character, followed by an ‘R’, followed by any string:

						$ ls ??R* 
BAREAD
					

In the following example, we list files that start with ‘conf’, followed by any two characters, followed by ‘.log’:

						$ ls conf.??.log 
conf12.log conf.23.log 
conf25.log
					

To match all filenames that start with ‘f’, followed by any two characters, followed by any string; the end character must be an ‘s’:

						$ ls f??*s 
ftpaccess      ftpconversions 
ftpgroups      ftphosts 
ftpusers
					

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