Linux with Operating System Concepts



Download 5,65 Mb.
Pdf ko'rish
bet29/254
Sana22.07.2022
Hajmi5,65 Mb.
#840170
1   ...   25   26   27   28   29   30   31   32   ...   254
Bog'liq
Linux-with-Operating-System-Concepts-Fox-Richard-CRC-Press-2014

Wildcard
Explanation
*
Match anything (0 characters or more)
?
Match any one character
[chars]
Match any one of the characters in the list
[char1-char2]
Match any one of the characters in the range from char1 to char 2 (e.g., [0–9], 
[a-e], [A-Z])
{word1,word2,word3}
Match any one of the words
[!chars]
Match any one character not in the list
TABLE 3.2 
Examples Using ls with Wildcards
ls Command
Result
ls *.txt
file1.txt file21.txt file2a.txt
file2.txt file_a.txt file.txt
ls *.*
file1.txt file21.txt file2a.txt
file2.txt file_a.txt file.txt
file.dat file1.dat file2.dat
ls *
All files
ls file?.*
file1.txt file2.txt file1.dat
file2.dat
ls file??.txt
file21.txt file2a.txt file_a.txt
ls file?.{dat,txt}
file1.dat file1.txt file2.dat
file2.txt
ls [abc][abc][abc]
aba abc
ls [!a]*
All files except for 
aba
and 
abc


Navigating the Linux File System

79
ls file1.txt file2.txt file1.dat
Thus, enumerating the list in braces does not seem worthwhile. However, the power of 
brace expansion comes when the items in braces are directories and subdirectories. If you 
use this correctly, it saves you from having to type full paths to each directory.
Consider the directory structure shown in Figure 3.3. If you wanted to perform some 
operation, say ls, on all of the subdirectories of foxr, you could do so with the following 
listing:
ls /home/foxr/temp /home/foxr/temp2 /home/foxr/temp2/a
/home/foxr/temp2/b
But this listing can be greatly simplified (reduced in size) using braces as shown here:
ls /home/foxr/{temp,temp2/{a,b}}
The above instruction is unfolded into the full list /home/foxr/temp, /home/foxr/temp2, 
/home/foxr/temp2/a, /home/foxr/temp2/b, without the user having to do so. Through brace 
expansion, you do not have to repeat all of the directory paths.
Through the use of .., ., ~, *, ?, [], and {}, the user is provided a number of very useful 
shortcuts to simplify paths. Recall from Section 2.6.3 that the Bash interpreter performs 
several steps before executing an instruction. With respect to these symbols, Bash first 
expands items found in braces. This is followed by replacing ~ with the appropriate home 
directory name. Next, globbing, or filename expansion, takes place replacing wildcards 
with lists of matching files and directories. Finally, the instruction can be executed on the 
resulting list(s) generated.
3.3 FILE SYSTEM COMMANDS
In this section, we examine many common Linux file system commands. This section does 
not include commands reserved for system administrators. Keep in mind that if you are 
attempting to apply an instruction on an item owned by another user, the command may 
bin
foxr
dukeg
temp
temp2
a
b
marst
zappaf
etc
home
usr
FIGURE 3.3 
Example directory structure.


80

Linux with Operating System Concepts
not work depending on that item’s permissions. We explore permissions in Section 3.5. 
We also visit some more special purpose file system commands at the end of this chapter.
One aspect of Linux which is most convenient is that many file system commands will 
operate on different types of file system constructs. These include files, directories, sym-
bolic links, pipes, I/O devices, and storage devices. We discuss the difference between these 
types in Chapter 10 although we also look at symbolic links in this chapter and pipes in 
other chapters.
The 
file
command will describe the type of entity passed to the command. For 
instance, 
file /etc/passwd
will tell us that this is ASCII text (a text file) while 
file 
/
will tell us that / is a directory and 
file /dev/sda1
will tell us that sda1 is a block 
special device (a special file for a block device). Other types that might be output from the 
file command include empty (an empty text file), a particular type of text file (e.g., C pro-
gram, bash shell script, Java program), symbolic link, and character special (character-type 
device). Using the -i option causes file to output the MIME type of the file as in 
text/
plain

application/x-directory

text/x-shellscript
, and others.
Table 3.3 displays the commands we will cover in Sections 3.3.1 through 3.3.5, along 
with a description of each command and the more common options. To gain a full under-
standing of each command, it is best to study the command’s main page.
3.3.1 Directory Commands
You will always want to know your current working directory. Without this knowledge, 
you will not be able to use relative paths. The command 
pwd
is used to print the current 
working directory. It is one of the simplest commands in Linux as it has no options. The 
command responds with the current working directory as output. For instance:
TABLE 3.3 
Common Linux File Commands

Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   25   26   27   28   29   30   31   32   ...   254




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish