Indlela yokusebenzisa i-Linux ukuthola umyalo wokuthola amafayela

Kulokhu okuthunyelwe sizobheka i-linux find umyalo nokuthi ungasesha kanjani futhi uthole amafayela anezimpawu ezahlukahlukene.

I-Linux thola i-Command

I-Linux find umyalo wakhiwe ngethuluzi elinamandla elingasetshenziswa ukuthola nokuphatha amafayela nezinkomba ngokuya ngemibandela ebanzi yokusesha.

Isibonelo, singathola amafayela ngamagama awo, isandiso, usayizi, izimvume, njll. Futhi singasebenzisa i- find umyalo wokusesha umbhalo othile ngaphakathi kwefayela esingalazi igama lalo.

Ake sibone ukusetshenziswa kwe- find umyalo ngezibonelo:

Isesha ifayela ngegama

Uma wazi igama lefayela kepha ungakhumbuli umkhombandlela okuwo ungasebenzisa umyalo olandelayo kusuka enkombeni yezimpande:

find . -name sales.csv

Ukukhishwa kwesampula:



./accounts/sales.csv

Isesha ifayela elithile enkombeni

Uma ufuna ukusesha amafayela athile kumkhombandlela, singasebenzisa:

find ./test -name testCases*

Ukukhishwa kwesampula:

./test/testCases10.txt ./test/testCasesPassed.txt ./test/testCasesFailed.log

Esimweni esingenhla, sisesha kuphela ngaphakathi komkhombandlela we './test'.

Thola amafayela ngokunwebeka

Ukusesha nokuthola amafayela ngesandiso esithile esisisebenzisayo:

find . -name *.jpg

Ukukhishwa kwesampula:

./test/results/failedTests.jpg ./test/project.jpg ./home/profile_pic.jpg ./tmp/cute-cats.jpg

Thola amafayela noma izinkomba ezinamagama athile

Ukuthola amafayela kuphela, sidinga ukusebenzisa -f inketho:

find ./ -type f -name 'results*'

Ukukhishwa kwesampula:

./test/results_latest.log ./test/results_archive.pdf

Ukuthola izinkomba kuphela, sidinga ukusebenzisa -d inketho:

find ./ -type d -name 'results*'

Ukukhishwa kwesampula:

./test/results

Thola amafayela kwizikhombisi eziningi

Uma ufuna ukusesha nokufaka kuhlu wonke amafayela anegama elinikeziwe kwizikhombisi eziningi ungaqala ukusesha kufolda yezimpande, noma uma wazi izinkomba, ungawacacisa.

Isibonelo:

find ./test ./logs -name failed*.* -type f

Ukukhishwa kwesampula:

./test/failed_tests.txt ./logs/failed_tests.log

Thola amafayela aqukethe umbhalo othile

Kwesinye isikhathi ufuna ukuthola ifayili futhi ungalazi igama lalo, kepha uyazi ukuthi linombhalo othile ngaphakathi kwalo.

Ungasebenzisa:

find ./test -type f -exec grep -l -i 'login_scenarios' {} ;

Lapha, i- -i inketho isetshenziselwa ukuziba icala, ngakho-ke i-Login_Scenarios ne-login_scenarios kuzotholakala zombili.

Thola amafayela ngosayizi

Singathola ngisho namafayela ngosayizi abahlukene. Izinketho zosayizi yilezi:

  • c amabhayithi
  • k ama-kilobyte
  • M Ama-Megabytes
  • G Ama-Gigabyte

Isibonelo ukuthola amafayela ngosayizi ngqo esiwasebenzisayo:

find / -size 10M

Futhi ukuthola amafayela amakhulu kunosayizi othile, sisebenzisa:

find ./test -size +2M

Lokhu okungenhla kuzowathola wonke amafayela amakhulu kuno-2MB kufolda ye- ./test.

Thola bese ususa amafayela athile

Ukuthola nokususa amafayela athile esiwasebenzisayo:

find . -type f -name 'temp*' -exec rm {} ;

Isiphetho

Kulesi sihloko ufunde ukuthi ungawusebenzisa kanjani umyalo wokuthola i-linux ukusesha amafayela asuselwa egameni, isandiso, usayizi nohlobo.