26.10.2012 Views

SUSE LINUX Documentation - Index of

SUSE LINUX Documentation - Index of

SUSE LINUX Documentation - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

and paths with the help <strong>of</strong> →| , you can simultaneously check whether the file or path<br />

you want to enter really exists (and you can be sure <strong>of</strong> getting the spelling right).<br />

Wild Cards<br />

Another convenience <strong>of</strong>fered by the shell is wild cards for pathname expansion. Wild<br />

cards are characters that can stand for other characters. There are three different types<br />

<strong>of</strong> these in Bash:<br />

?<br />

*<br />

Matches exactly one arbitrary character<br />

Matches any number <strong>of</strong> characters<br />

[set]<br />

Matches one <strong>of</strong> the characters from the group specified inside the square brackets,<br />

which is represented here by the string set. As part <strong>of</strong> set you can also specify<br />

character classes using the syntax [:class:], where a class is one <strong>of</strong> alnum,<br />

alpha, ascii, etc.<br />

Using ! or ^ at the beginning <strong>of</strong> the group ([!set]) matches one character other than<br />

those identified by set.<br />

Assuming that your test directory contains the files Testfile, Testfile1,<br />

Testfile2, and datafile, the command ls Testfile? lists the files<br />

Testfile1 and Testfile2. With ls Test*, the list also includes Testfile.<br />

ls *fil* shows all the sample files. Finally, you can use the set wild card to address<br />

all sample files whose last character is a number: ls Testfile[1-9] or, using<br />

classes, ls Testfile[[:digit:]].<br />

Of the four types <strong>of</strong> wild cards, the most inclusive one is the asterisk. It could be used<br />

to copy all files contained in one directory to another one or to delete all files with one<br />

command. The command rm *fil*, for instance, would delete all files in the current<br />

directory whose name includes the string fil.<br />

Working with the Shell 99

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!