Mashandisiro ekushandisa iyo Linux tsvaga rairo yekuwana mafaera

Mune ino posvo tichatarisa iyo linux find raira uye maitiro ekutsvaga nekuwana mafaera ane hunhu hwakasiyana.

Linux tsvaga Raira

Iyo Linux find rairo rakavakirwa mune chakasimba chishandiso chinogona kushandiswa kutsvaga nekutarisa mafaera uye madhairekitori zvichibva pane dzakasiyana siyana nzira dzekutsvaga.

Semuenzaniso, tinogona kuwana mafaera nemazita avo, kuwedzera, saizi, mvumo, nezvimwe. Tinogona zvakare kushandisa find raira kutsvaga rumwe rugwaro mukati mefaira iyo yatisingazive zita rayo.

Ngatione kumwe kushandiswa kwe find raira nemienzaniso:

Kutsvaga faira nemazita

Kana iwe uchiziva zita refaira asi usingakwanise kurangarira dhairekitori irimo iwe unogona kushandisa unotevera kuraira kubva kumudzi dhairekitori:

find . -name sales.csv

Semuenzaniso kuburitsa:



./accounts/sales.csv

Kutsvaga yakatarwa faira mune dhairekitori

Kana iwe uchida kutsvaga chaiyo faira (s) mune dhairekitori, tinogona kushandisa:

find ./test -name testCases*

Semuenzaniso kuburitsa:

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

Munyaya iri pamusoro, isu tiri kungotsvaga mukati me './test' dhairekitori.

Tsvaga mafaera nekuwedzera

Kutsvaga nekutsvaga mafaera neimwe yekuwedzera yatinoshandisa:

find . -name *.jpg

Semuenzaniso kuburitsa:

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

Tsvaga mafaera kana madhairekitori ane mamwe mazita

Kuti uwane chete mafaera, tinofanirwa kushandisa -f sarudzo:

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

Semuenzaniso kuburitsa:

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

Kuti tiwane madhairekitori chete, tinofanirwa kushandisa -d sarudzo:

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

Semuenzaniso kuburitsa:

./test/results

Tsvaga mafaera mune akawanda madhairekitori

Kana iwe uchida kutsvaga uye kunyora ese mafaera ane zita rakapihwa mune akawanda madhairekitori iwe unogona kana kutanga kutsvaga pamidzi folda, kana kana iwe uchiziva madhairekitori, unogona kudoma iwo.

Muenzaniso:

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

Semuenzaniso kuburitsa:

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

Tsvaga mafaera ane chimwe chinyorwa

Dzimwe nguva iwe unoda kutsvaga faira uye iwe hauzive zita rayo, asi iwe unoziva kuti rine imwe chinyorwa mukati maro.

Unogona kushandisa:

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

Pano, iyo -i sarudzo inoshandiswa kushaya hanya nenyaya, saka Login_Scenarios uye login_scenarios zvese zvichawanikwa.

Tsvaga mafaera nesaizi

Isu tinogona kunyange kutsvaga mafaera nemhando dzakasiyana. Saizi sarudzo ndeiyi:

  • c byte
  • k kilobytes
  • M Megabhayithi
  • G Gigabytes

Semuenzaniso kutsvaga mafaera pane saizi chaiyo yatinoshandisa:

find / -size 10M

Uye kutsvaga mafaera akakura kupfuura imwe saizi, isu tinoshandisa:

find ./test -size +2M

Izvo zviri pamusoro zvichawana mafaera ese akakura kupfuura 2MB mune ./test folda.

Tsvaga uye bvisa chaiwo mafaira

Kuti uwane uye kudzima mafaera chaiwo atinoshandisa:

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

Mhedziso

Muchikamu chino iwe wakadzidza nezve mashandisiro ekushandisa linux tsvaga rairo yekutsvaga mafaera zvinoenderana nezita, kuwedzerwa, saizi uye mhando.