Suse Linux Professional 9.2 Upgrade [Strong Encryption 128 Bit] 00662644457260 User Manual

Product codes
00662644457260
Page of 324
21
W
or
king
with
the
Shell
1. Change into your home directory with the command
cd
. Then create a di-
rectory in it with the name
test2
by entering
mkdir test2
.
2. Change into the new directory with
cd test2
and create a subdirectory
in it with the name
subdirectory
. To change into it, use the expansion
function: enter
cd su
then press




Tab
. The shell will expand the rest of the
directory name.
3. Now try to move the previously created file
Testbackup
into the
current directory (
subdirectory
) without changing the direc-
tory again. To achieve this, specify the relative path to that file:
mv
../../test/Testbackup .
. The dot at the end of this command is re-
quired to tell the shell that the current directory is the destination to which
to move the file.
../../
, in this example, refers to your home directory.
21.1.5
Wild Cards
Another convenience offered by the shell is wild cards. There are four different
types of these in Bash:
?
Matches exactly one arbitrary character
*
Matches any number of characters
[set]
Matches one of the characters from the group specified inside the square
brackets, which is represented here by the string set
[!set]
Matches one character other than those identified by set
Assuming that your
test
directory contains the files
Testfile
,
Testfile1
,
Testfile2
, and
datafile
, the command
ls Testfile?
lists the files
Testfile1
and
Testfile2
. With
ls Test*
, the list will also include
Testfile
. The command
ls *fil*
shows all the sample files. Finally, you can
use the
set
wild card to address all sample files whose last character is a num-
ber:
ls Testfile[1-9]
.
Of the four types of wild cards, the most inclusive one is the asterisk. It could be
used to copy all files contained in one directory to another one or to delete all files
with one command. The command
rm *fil*
, for instance, would delete all files
in the current directory whose name includes the string fil.
261
SUSE LINUX