Linux with Operating System Concepts



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

username
is the current user’s username.
3.2.4 Specifying Filenames with Wildcards
A wildcard is a way to express a number of items (files, directories, links) without having 
to enumerate all of them. The most common wildcard is *, which represents “all items.” By 
itself, the * will match any and every item in the current directory. For instance, 
ls *
lists 
all items in the current directory. You can combine the * with a partial description of item 
names. When appended with .txt, the * specifies “match all items whose name ends with 
.txt.” For instance, 
ls *.txt
lists all items whose names end with the .txt extension in the 
current working directory.
The Linux interpreter performs an operation called 
filename expansion
, or 
globbing

prior to executing an instruction. The interpreter converts any wildcard(s) given in the 
instruction into a list of all items that match the combination of wildcard(s) and literal 
characters. In the command 
ls *.txt
, the interpreter first expands *.txt into the list 
of filenames ending with .txt. Another example would be 
ls a*
which would match all 
items whose names start with the lower case ‘a’. The interpreter compiles the list of all 
matching items, and then replaces *.txt or a* with the list generated. Now, the ls command 
can be performed.


78

Linux with Operating System Concepts
Table 3.1 lists the available wildcards in Bash. There are additional wildcards that can be 
used in Bash, but they require specific installation.
Assume the current working directory has the following files:
file.txt file1.txt file2.txt file2a.txt file21.txt file_a.txt 
file_21.txt file.dat file1.dat file2.dat abc bcd aba bb
Table 3.2 provides several example listings using ls and different wildcard combina-
tions. Wildcards can be confusing. The best way to learn them is through practice. Later in 
the text, we will look at regular expressions, which also use *, ?, and []. Unfortunately, the 
interpretation of * and ? differ in regular expressions, which will further complicate your 
ability to use them.
One set of wildcards, as shown in Figure 3.2, is the braces, or {} characters. Here, you 
can enumerate a list of items separated by commas. The Bash interpreter uses brace expan-
sion to unfold the list. Recall that the ls command can receive a list of items as in the fol-
lowing instruction.
TABLE 3.1 
Wildcards in Linux

Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   24   25   26   27   28   29   30   31   ...   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