Indlela yokusebenzisa iLinux ukufumana umyalelo wokufumana iifayile

Kule posi siza kujonga kwi-linux find umyalelo kunye nendlela yokukhangela nokufumana iifayile ezineempawu ezahlukeneyo.



I-Linux fumana Umyalelo

I-Linux find Umyalelo wakhiwe kwisixhobo esinamandla esinokusetyenziselwa ukufumana nokulawula iifayile kunye nemikhombandlela esekwe kuluhlu olubanzi lweendlela zokukhangela.

Umzekelo, sinokufumana iifayile ngegama labo, ulwandiso, ubungakanani, iimvume, njl.njl. Kananjalo sinokusebenzisa find ukuyalela ukukhangela isicatshulwa esithile ngaphakathi kwifayile esingalazi igama layo.


Makhe sibone ukusetyenziswa | | + _ | | umyalelo ngemizekelo:

Ukukhangela ifayile ngegama

Ukuba uyazi igama lefayile kodwa ungalikhumbuli ulawulo olukulo ungasebenzisa lo myalelo ulandelayo ukusuka kulawulo lweengcambu:


find

Iziphumo zesampulu:



find . -name sales.csv

Ukukhangela ifayile ethile kulawulo

Ukuba ufuna ukukhangela iifayile (ezithile) ezithile kulawulo, sinokusebenzisa:

./accounts/sales.csv

Iziphumo zesampulu:

find ./test -name testCases*

Kule meko ingentla, sikhangela kuphela ngaphakathi kulawulo './test'.


Fumana iifayile ngokwandiswa

Ukukhangela kunye nokufumana iifayile ngolwandiso oluthile esilusebenzisayo:

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

Iziphumo zesampulu:

find . -name *.jpg

Fumana iifayile okanye izikhombisi ezinamagama athile

Ukufumana iifayile kuphela, kufuneka sisebenzise ./test/results/failedTests.jpg ./test/project.jpg ./home/profile_pic.jpg ./tmp/cute-cats.jpg ukhetho:

-f

Iziphumo zesampulu:


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

Ukufumana kuphela izikhombisi, kufuneka sisebenzise ./test/results_latest.log ./test/results_archive.pdf ukhetho:

-d

Iziphumo zesampulu:

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

Fumana iifayile kwizikhombisi ezininzi

Ukuba ufuna ukukhangela kunye nokudwelisa zonke iifayile ezinegama elinikiweyo kwizikhombisi ezininzi ungaqala ukukhangela kwifolda yengcambu, okanye ukuba uyazi izikhombisi, ungazichaza.

Umzekelo:


./test/results

Iziphumo zesampulu:

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

Fumana iifayile ezinombhalo othile

Ngamanye amaxesha ufuna ukufumana ifayile kwaye awazi igama layo, kodwa uyazi ukuba inombhalo othile ngaphakathi kuyo.

Ungasebenzisa:

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

Apha, find ./test -type f -exec grep -l -i 'login_scenarios' {} ; inketho isetyenziselwa ukungahoyi imeko, ke Login_Scenarios kunye login_scenarios ziya kufunyanwa zombini.


Fumana iifayile ngokobungakanani

Singafumana iifayile ngokobungakanani obahlukeneyo. Izinketho zobungakanani zezi:

  • -i ii-byte
  • c iikhilobytes
  • k Megabytes
  • M IiGigabytes

Umzekelo ukufumana iifayile ngokobungakanani ngqo esizisebenzisayo:

G

Kwaye ukufumana iifayile ezingaphezulu kobukhulu obuthile, sisebenzisa:

find / -size 10M

Oku kungasentla kuya kufumana zonke iifayile ezinkulu kune-2MB kwifolda ./test.

Fumana kwaye ucime iifayile ezithile

Ukufumana nokucima iifayile ezithile esizisebenzisayo:

find ./test -size +2M

Isiphelo

Kule nqaku ufunde malunga nendlela yokusebenzisa i-linux find command ukukhangela iifayile ezisekwe kwigama, ulwandiso, ubungakanani kunye nohlobo.