Maitiro ekudzima mafaera ese kunze kweimwe kubva dhairekitori

bvisa mafaera eLinux

Dzimwe nguva unoda bvisa angangoita ese mafaera mudhairekitori, asi iwe unoda kuchengeta imwe kana zvimwe zvacho. Kana paine huwandu hwadzo hukuru, kuenda rimwe nerimwe ibasa rinonetesa. Haisi iyo yakanyanya kunaka sarudzo, pane nzira dzekuita kuti basa muLinux rive nyore uye kuti iwe unogona kubvisa ese iwo aunoda kamwechete.

Semuenzaniso, iwe ungangoda kubvisa chete iwo anotanga neimwe zita, kana ayo ane chairo kuwedzera, zvichingodaro. Zvese izvo zvinogonekaMuchokwadi, pane dzimwe nguva ini ndatoratidza zvakafanana dzidziso muLxA. Pano iwe unogona kutevedzera dzidziso nhanho nhanho uye nenzira yakapusa yekukwanisa kudzima ese mafaera aunoda, kunze kwezvaunoda kusevha.

Uye chinhu chakanakisa ndechekuti hauzodi kuisa chero chirongwa, zvinogona kuitwa zvirinyore nemirairo senge rm uye uwane. Ndokunge, mapurogiramu akatove akaiswa-pamberi pane chero Linux distro. Uye zvechokwadi, nzira yacho ichave inoenderana nekutsvaga mapatani uye kushandisa iwo machisi kubvisa chete zvaunoda.

Zvakanaka, kuitira kubvisa ipapo dzimwe nzira dzinoverengeka, Ndezvipi…

Bvisa mafaera kubva dhairekitori ne rm

Zvakanaka, kuti ushandise iyo rm raira Kuti ubvise zvaunonzwa kuita, iwe unofanirwa kuziva pamberi pedzimwe nzira dzekuziva mapatani.

  • * (rondedzero yemapatani) - inofanidza zero kana zvimwe zvinoitika zvemapatani akataurwa
  • ? (rondedzero yemapatani) - inofanidza zero kana chimwe chiitiko chemaitiro akataurwa
  • + (muenzaniso runyorwa) - inofanidza chimwe kana zvimwe zvinoitika zvemaitiro akataurwa
  • @ (runyorwa rwemhando) - inofanidza imwe yemapatani akataurwa
  • (runyorwa rwemhando) - inofanidza chero chinhu kunze kweimwe yemapatani akapihwa

Para shandisa extglob Kuti uvashandise, unofanirwa kutanga waita unotevera kuraira:

<br data-mce-bogus="1">

shopt -s extglob<br data-mce-bogus="1">

 

 

ziso! Handitaure nezvazvo, asi zvinofungidzirwa kuti une mvumo yekuita mashandiro aya, uye kuti iwe uri mukati medhairekitori iyi kana iwe uchiita iyo rm yekuraira. Ive nekuchenjerera neizvi, nekuti kana ukamhanya nayo mune imwe nzira, unogona kupedzisira wabvisa mafaera ausingade. Ndokunge, usati waita iyi mirairo, ita shuwa kuti wapinda dhairekitori raunoda ne cd.

Iye zvino unogona kushandisa rm kubvisa chero chaunoda. Semuyenzaniso, bvisa mafaera ese mudhairekitori kunze kweaya anoenderana nezita racho «Lxa»:

rm -v !("lxa")

Iwe unogona zvakare kudoma mazita maviri kana anopfuura ausingade kudzima. Semuenzaniso, kudzivirira kubvisa "lxa" uye "desdelinux":

 rm -v !("lxa"|"desdelinux") 

Unogona kudzima mafaera ese, kubvisa izvo nekuwedzera .mp3. Semuyenzaniso:

 rm -v !(*.mp3) 

Pakupera, unogona kudzokera ku dzima extglob:

 shopt -u extglob 

Bvisa mafaera kubva kudhairekitori nekutsvaga

Imwe nzira yekuita rm ndeye shandisa find kubvisa chero chaunofarira. Iwe unogona kushandisa pombi uye xargs ne rm, kana kushandisa iyo -sarudza sarudzo kuti uwane. Ndokunge, generic syntax ingave iri:

find /directory/ -type f -not -name 'PATRÓN' -delete
find /directory/ -type f -not -name 'PATRÓN' -print0 | xargs -0 -I {} rm [opciones] {}

Semuenzaniso, fungidzira iwe uchida bvisa mafaera ese mudhairekitori kunze kweavo vane yekuwedzera .jpg, unogona kushandisa mumwe wemirairo iyi miviri, nekuti ivo vaviri vanowana mhedzisiro yakafanana:

find . -type f -not -name '*.jpg'-delete

find . -type f -not -name '*.jpg' -print0 | xargs -0 -I {} rm -v {}

Pane kudaro, kana iwe waida wedzera imwe pateni, iwe unogona zvakare. Semuenzaniso, ngatiti haudi kubvisa iyo .pdf kana .odt kubva kudhairekitori:

find . -type f -not \(-name '*pdf' -or -name '*odt' \) -delete

Ehe, iwe unogona kuita zvakafanana ne | uye xargs semumuenzaniso wapfuura. Nenzira, isu tashandisa -kusaramba, asi iwe unogona kubvisa izvo kuti zviite zvakanaka, ndiko kuti, kubvisa mapatani akafanana uye kwete kuvasiya.

Delete mafaera kubva kudhairekitori uchishandisa iyo GLOBIGNORE musiyano

Pakupedzisira, pane Imwe nzira kutsvaga uye rm, uye irikushandisa nharaunda inonongedzera kunongedza mafaera iwe aunoda kubvisa kana kusarudzira. Semuenzaniso, fungidzira kuti iwe unoda kudzima mafaera ese mune dhairekitori inonzi Kurodha pasi, kuchengetedza iyo .pdf, .mp3 uye .mp4 mafaera. Pakadaro, unogona kuita zvinotevera:

cd Descargas
GLOBIGNORE=*.pdf:*.mp4:.*mp3
rm -v *
unset GLOBIGNORE


Izvo zviri muchinyorwa zvinoomerera pamisimboti yedu ye tsika dzekunyora. Kuti utaure chikanganiso tinya pano.

Iva wekutanga kutaura

Siya yako yekutaura

Your kero e havazobvumirwi ichibudiswa.

*

*

  1. Inotarisira data: AB Internet Networks 2008 SL
  2. Chinangwa cheiyo data: Kudzora SPAM, manejimendi manejimendi.
  3. Legitimation: Kubvuma kwako
  4. Kutaurirana kwedata
  5. Dhata yekuchengetedza: Dhatabhesi inobatwa neOccentus Networks (EU)
  6. Kodzero: Panguva ipi neipi iwe unogona kudzora, kupora uye kudzima ruzivo rwako