Skip to content Skip to content


How to resolve the '/bin/rm: Argument list too long' error Kā atrisināt '/ bin / rm: Argumentu saraksts ir pārāk garš "kļūda

Linux

root@dwarf /var/spool/clientmqueue # rm spam-* root @ punduris / var / spool / clientmqueue # rm spam-*
/bin/rm: Argument list too long. / bin / rm: Argumentu saraksts ir pārāk garš.

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 * ? Kādreiz redzējis šo kļūdu, Linux, ja Jums ir pārāk daudz failus direktorijā un nevarat dzēst tos ar vienkāršu rm-RF *? I have run into this problem a number of times. Man ir palaist šo problēmu reižu skaitu. After doing a bit of research online I came across a neat solution to work around this issue. Pēc dara mazliet pētniecības tiešsaistē Man nāca pāri veikls risinājums, lai novērstu šo problēmu.

find . atrast. -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- . In virs piemēram komanda sparīgi izdzēst visus pašreizējā direktorijā failus, kas sākas ar spam-. You can replace the spam-* with anything you like. Jūs varat nomainīt spam-* ar visu, kas jums patīk. You can also replace it with just a * if you want to remove all files in the folder. Jūs varat arī aizvietot tikai ar * Ja vēlaties noņemt visus failus mapē.

find . atrast. -name '*' | xargs rm -name '*' | xargs rm

We have covered the Mums ir, uz Linux find Linux atrast command in great detail earlier. komandu detalizēti agrāk. Xargs Xargs is Linux command that makes passing a number of arguments to a command easier. ir Linux komanda, kas padara iet vairākus argumentus, lai komanda vieglāk.

Posted in Posted in Linux Linux . .

Get Simple Help tutorials just like this one in your email inbox every day - for free! Get Simple Palīdzība konsultācijas tāpat kā šo vienu savā e-pastā ik dienas - bez maksas! Just enter your email address below: Vienkārši ievadiet savu e-pasta adresi:

You can always opt out of this email subscription at any time. Jūs vienmēr varat atteikties no šīs e-pasta abonementu jebkurā laikā.

3 Responses 3 Atbildes

Stay in touch with the conversation, subscribe to the Uzturēt kontaktus ar sarunu, abonēt RSS feed for comments on this post RSS barību komentārus par šo ziņu . .

  1. Aleš Friedl says Aleš Friedl saka

    Safe variant for filenames with spaces, new lines and other whitespace characters: Drošs variants filenames ar atstarpēm, jaunu līniju un citu atstarpes rakstzīmes:
    find . atrast. -name '*' -print0 | xargs -o rm -name '*'-print0 | xargs-o rm

  2. MikeT says MikeT saka

    Good catch using the print0 option, that's an important one. Good catch izmantojot print0 iespēju, ka ir svarīgs.

    Most find commands do not require the “-name” predicate. Visvairāk atrast komandas neprasa "-name" predikāts. What's usually more important is to make sure you're deleting *files* and not something else you might not have intended. Kas parasti ir vairāk svarīgi ir pārliecināties, jūs dzēšot * files * un nevis kaut kas cits Iespējams, nav paredzēta. For this use “-type f” inplace of the “-name” option…. Šādai izmantošanai "tipa f" inplace par "-vārdu" variantu ....

    find . atrast. -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. ) Izmantojiet pilnu ceļu uz "rm" komandu, lai jūsu pseidonīmi nav piemēslot ar lietām.
    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) Pārbaudiet savu xargs komandu, var dažreiz, ja vajadzīgs, informējiet par to lietot vienu "rezultāts" uz laiku, piemēram, (ja tu neizmanto print0 bet regulāras print) "-L1"

  3. myhnet myhnet says saka

    find . atrast. -type f -exec rm {} \; -type f-exec rm () \;



Some HTML is OK Daži HTML ir OK

or, reply to this post via vai, atbildot uz šo ziņu izmantojot trackback Trackback . .