How to resolve the '/bin/rm: Argument list too long' error Ako vyriešiť '/ bin / rm: Argument list príliš dlhý' error

by Sukrit Dhandhania on February 18, 2009 používateľa Sukrit Dhandhania dňa 18.února 2009

Linux

root@dwarf /var/spool/clientmqueue # rm spam-* root @ trpasličí / var / spool / clientmqueue # rm-spam *
/bin/rm: Argument list too long. / Bin / rm: Argument list príliš dlho.

Ever seen this error in Linux when you have too many files in a directory and you are unable to delete them with a simple rm -rf * ? Videl táto chyba v Linuxu, keď máte príliš veľa súborov v adresári, a nie ste schopní ich odstrániť s jednoduchým rm-rf *? I have run into this problem a number of times. Musím bežať na tento problém niekoľkokrát. After doing a bit of research online I came across a neat solution to work around this issue. Potom, čo robí trochu výskumu online som narazil elegantné riešenie pre tento problém obísť.

find . nájsť. -name 'spam-*' | xargs rm -name 'spam-*' | xargs rm

In the above instance the command will forcefully delete all files in the current directory that begin with spam- . Vo vyššie uvedenom prípade príkaz silno vymazať všetky súbory v aktuálnom adresári, ktoré začínajú-spam. You can replace the spam-* with anything you like. Môžete nahradiť spam-* s prakticky čokoľvek. You can also replace it with just a * if you want to remove all files in the folder. Môžete tiež nahradiť len * Ak chcete odstrániť všetky súbory v priečinku.

find . nájsť. -name '*' | xargs rm -name '*' | xargs rm

We have covered the Máme na ktoré sa vzťahuje Linux find Linux nájdete command in great detail earlier. Príkaz veľmi podrobne predtým. Xargs Xargs is Linux command that makes passing a number of arguments to a command easier. Linux je príkaz, ktorý robí okolo niekoľko argumentov na príkaz jednoduchšie.

Related Posts: Súvisiace zmeny:
  • How to install and manage packages in Linux with RPM Ako nainštalovať a spravovať balíky v Linuxe s RPM
  • Windows XP Recovery System Features Zotavení systému Windows XP Systémové funkcie
  • Technology and Lifestyle Technológia a životný štýl
  • How to resolve Windows Vista Update error 800B0100 Ako riešiť Windows Vista Update error 800B0100
  • Pownce overview and 10 invites for Simplehelp Readers Pownce prehľad a 10 pozýva na Simplehelp Čitatelia
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! Get Help jednoduchá cvičenie, rovnako ako to vo vašej e-mailovej schránky každý deň - zadarmo! Just enter your email address below: Stačí zadať e-mailovú adresu:

    You can always opt out of this email subscription at any time. Vždy sa môžete odhlásiť z tohto e-mailu predplatného kedykoľvek.

    { 3 comments… read them below or (3 komentáre ... prečítať nižšie alebo add one pridať jedno } )

    1 1 Aleš Friedl 02.19.09 at 7:16 am Aleš Friedl 02.19.09 v 7:16 am

    Safe variant for filenames with spaces, new lines and other whitespace characters: Bezpečné variant pre názvy súborov s medzerami, nové trate a ďalšie prázdne znaky:
    find . nájsť. -name '*' -print0 | xargs -o rm -name '*'-print0 | xargs rm-o

    2 2 MikeT 02.19.09 at 6:30 pm MikeT 02.19.09 v 6:30 pm

    Good catch using the print0 option, that's an important one. Dobrá partia pomocou print0 voľby, to je dôležitý.

    Most find commands do not require the “-name” predicate. Väčšina nájsť príkazy nevyžadujú "-name" predikát. What's usually more important is to make sure you're deleting *files* and not something else you might not have intended. Čo je zvyčajne dôležitejšie je, aby sa uistili, že ste mazanie súborov * *, a nie niečo, čo by ste mohli nie je určená. For this use “-type f” inplace of the “-name” option…. Pre toto použitie "-type f" InPlace na "-name" voľby ....

    find . nájsť. -type f -print0 | xargs -0 /bin/rm -type f-print0 | xargs -0 / bin / rm

    A) Use the full path to the 'rm' command so your aliases don't muck with things. ) Používajte úplnú cestu k 'rm' príkaz, aby sa vaše aliasy nemajú bahna s vecami.
    B) Check your xargs command, you can sometimes, if needed, tell it to use one “result” at a time, such as (if you didn't use print0 but regular print) “-l1″ B) Skontrolujte si xargs príkaz, môžete si niekedy, v prípade potreby, povedz to používať jednu "výsledok" v čase, ako je (ak ste nepoužili print0, ale pravidelný tlač) "-L1"

    3 3 myhnet myhnet 02.25.09 at 12:12 am 02.25.09 v 1212: am

    find . nájsť. -type f -exec rm {} \; -type f-exec rm () \;

    Leave a Comment Zanechať komentár

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> Môžete použiť tieto HTML tagy a atribúty: href = "" <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> del datetime <em> <i> <q Cite=""> <strike> <strong>