システム上の目的のファイルまたは情報をすばやく見つけることが重要な場合があります。ファイルマネージャが現在持っている標準の検索機能に制限できる場合もありますが、それらは端末の機能と比較できません。
find – , , :
- .
- .
- .
:
- .
- .
- .
find Linux .
find:
$ find directory-to-search criteria action
:
- directory-to-search ( ) – , find , . , ;
- criteria () – , ;
- action () – , .
s.txt :
$ find . -name "s.txt"
./s.txt
:
- . () –
- -name – . .
-name S.txt . –iname.
$ find . -iname "s.txt"
./s.txt
./S.txt
c .png *.png:
$ find . -name "*.png"
./babutafb.png
./babutafacebook.png
./Moodle2.png
./moodle.png
./moodle/moodle1.png
./genxfacebook.png
. , find png home:
$ find /home -name "*.png"
find: `/home/babuta/.ssh': Permission denied
/home/vagrant/Moodle2.png
/home/vagrant/moodle.png
/home/tisha/hello.png
find: `/home/tisha/testfiles': Permission denied
find: `/home/tisha/data': Permission denied
/home/tisha/water.png
find: `/home/tisha/.cache': Permission denied
, – 2> /dev/null. dev/null, .
find /home -name "*.jpg" 2>/dev/null
/home/vagrant/Moodle2.jpg
/home/vagrant/moodle.jpg
/home/tisha/hello.jpg
/home/tisha/water.jpg
-type , :
- f – ;
- d – ;
- l – ;
- b – (dev);
- c – (dev);
- p – ;
- s – ;
, -type d :
$ find . -type d
.
./.ssh
./.cache
./moodle
, . -size.
- "+" —
- "-" —
- , .
1 (+1G).
$ find . -size +1G
./Microsoft_Office_16.29.19090802_Installer.pkg
./android-studio-ide-183.5692245-mac.dmg
:
- c —
- k —
- M —
- G —
-empty .
$ find . -empty
./.cloud-locale-test.skip
./datafiles
./b.txt
...
./.cache/motd.legal-displayed
-cmin . , ( 60 ), -60:
$ find . -cmin -60
.
./a.txt
./datafiles
, ( 60 ).
, +60.
$ find . -cmin +60
-atime .
$ find . -atime +180
, (180 ).
–user username , :
$ find /home -user tisha 2>/dev/null
tisha home, 2>/dev/null .
-perm – .
$ find /home -perm 777
777.
:
- -and
- -or
- -not
, 1 tisha :
$ find /home -user tisha -and -size +1G 2>/dev/null
tisha, pokeristo, 1 .
$ find /home \( -user pokeristo -or -user tisha \) -and -size +1G 2>/dev/null
"\".
find , .
- -delete —
- -ls — :
- .
- inode.
- -print , . .
- -exec .
-delete
, , :
$ find . -empty -delete
. -print.
-exec:
.
-exec command {} \;
:
- command – , . :
- rm
- mv
- cp
- {} – .
- \; — .
–exec –delete :
$ find . -empty -exec rm {} \;
-exec:
$ find . -name "*.jpg" -exec cp {} /backups/fotos \;
.jpg backups/fotos
find :
- .
- .
- .
- ( ).
- .
- .
- .
- .
, :
- .
- .
- .
find , – .