Linux with Operating System Concepts



Download 5,65 Mb.
Pdf ko'rish
bet38/254
Sana22.07.2022
Hajmi5,65 Mb.
#840170
1   ...   34   35   36   37   38   39   40   41   ...   254
Bog'liq
Linux-with-Operating-System-Concepts-Fox-Richard-CRC-Press-2014

directory options
where directory is the starting position in the file system for the search to begin. There 
are several different forms of options discussed below but at least one form of the options 
(expression) is required.
The simplest form of find is to locate files whose name matches a given string. The string 
can include wildcard characters. As an example, if you want to find all .conf files in the /etc 
directory (and its subdirectories), you would issue the instruction
FIGURE 3.5 
GUI search for files tool.


Navigating the Linux File System

95
find /etc -name “*.conf”
Notice that the instruction
ls /etc/*.conf
is similar but in ls, you are only examining files in /etc, not its subdirectories. You could use 
-R in ls to recursively search all subdirectories so it performs similarly to find. A variation 
of the option -name is -iname, which does the same thing but is case insensitive.
The find command provides numerous options which increase its usefulness over the ls 
command. Options are divided into three categories. First are options similar to most Linux 
commands which cause the program to function differently. Second are options that the 
user specifies to tailor the search. These are 
search criteria
. Table 3.6 illustrates some of the 
more useful expressions. Third are options that control what find will do when it has located 
an item that matches the expression(s). We will consider these later in this subsection.
The notation 
[
+
-]n
from Table 3.6 needs a bit of explanation. These expressions can 
either be followed by an integer number, a 
+
integer or a –integer. The integer by itself, n, 
means an exact match. The values 
+
n and –n indicate “greater than n” and “less than n,” 
respectively. For instance
-size 1000c
means “exactly 1000 bytes in size” while 
–size 
-1000c
means “less than 1000 bytes in size.”
The various expressions listed in Table 3.6 can be combined using Boolean connectors. 
To specify that two (or more) expressions must be true, combine them with 
–and
or 
–a
(or 
just list them). For instance, the following three are all equivalent, which will seek out all 
files under the user’s home directory that are between 100 and 200 bytes.
• find ~ -size 
+
100c -size -200c
• find ~ -size 
+
100c -a -size -200c
• find ~ -size 
+
100c -and -size -200c
To specify that any of the expressions should be true, combine them with 
–o
or 
–or

The following expression looks for any item owned by user 500 or group 500.
• find ~ -uid 500 -o -gid 500
To specify that the given expression must not be true, use either 
!
expression or 
–not

For instance, the following two both search for noncharacter-based files.
• find ~ ! -type c
• find ~ -not -type c
If your expression contains numerous parts and you need to specify operator prece-
dence, place them within parentheses. Without parentheses, not is applied first, followed 
by and, followed by or.


96

Linux with Operating System Concepts
There are five options available for find. The first three deal with the treatment of sym-
bolic links. The option -P specifies that symbolic links should never be followed. This is 
the default behavior and so can be omitted. The option -L forces symbolic links to be fol-
lowed. What this means is that if an item in a directory is actually a symbolic link, then the 
expression is applied not to the link but to the item being pointed at. So for instance, if a 
symbolic link points to a character-type file and the expression is 
-type c
, then the file 
will match. If instead, option -P (or the default) is used, the file does not match because the 
symbolic link is not a character-type file.
The option -H is a little trickier to understand. Like -P, it prevents find from following 
symbolic links when searching for files. However, as we will see below, find can also have 
an action to perform on any item that matches the expression. With -H, while find does not 
follow symbolic links to identify a file, symbolic links can be followed when performing an 
action. As this is a complex concept, we will not go into it in any more detail.
The final two options are to receive debugging information and ordering of expressions. 
Debugging information is useful if you suspect that your find operation has some errors in 
its logic or is not efficiently organized. To specify debugging use the option -D and follow 
TABLE 3.6 
Expressions Used in Find

Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   34   35   36   37   38   39   40   41   ...   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