Re: Argument list too long

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robin Laing wrote:
> I will have to find some time to do some searching.  Most posts are
> not a problem.  It is the ones where someone takes a video and
> creates a 3000 part post in yenc.  I have not tried this in the
> latest Pan due to many other tasks at hand.  I will have to find a
> DVD that I want to download. :)

Hmmm, I suppose it sounds bad to wish you luck in reproducing the bug.
So I guess my hope is that you find out the bug has already been
fixed.  If not, we can find a work-around and make sure that the bug
gets reported upstream (if it hasn't been already).

>> Check out the archives, Steven W. Orr has posted numerous times
>> with good examples of xargs usage (I think he may be part of some
>> shady xargs cult ;).
>
> Cool, where do I sign up.  No really in my case it is practice that
> makes perfect.  Somethings I only learn by doing.

Yeah, I'm with you on that.  Let's say you've got those 3000 parts
from a usenet post in a directory.  You've given up trying to decode
them and you want to just delete them.  But "rm *" fails because their
are too many files.  Ignoring the fact that you could just cd up a
level and remove the entire directory, you could use xargs like so:

$ ls | xargs rm

Note that xargs will be using rm, not any alias you may have for rm,
so if you alias rm="rm -i" to protect yourself from accidental
deletions, that will not save you when using xargs.  So be careful
with dangerous commands like rm.

Other times you may need to move a large number of files and "mv * ~/"
may fail.  You can't quite use "ls | xargs mv ~/" because you need the
destination folder to be last.  You could do it like this instead:

$ ls | xargs -I {} mv {} ~/

The "-I {}" will make xargs use {} as a replacement string for each of
the filenames returned by ls.

As you can see, I suck at coming up with examples.  It's far easier to
come up with various ways to solve actual problems.  I'm not familiar
with decoding usenet posts.  Perhaps you can explain what it is that
you might do to decode a large post from multiple parts?  Then that
can be used as an example of how to use xargs in situations where the
"argument list too long" error could bite you.

Also, a quick google for xargs usage turns up a decent amount of
information and better examples.

> I find my way around it.  The last time I tried playing with xargs
> it was with one of these mutlipost files.  I had to feed it to the
> yenc decoder.  It was a character issue as I changed the file names
> to something that was only 5 or 6 characters and it ran with no
> problems.

You mean without xargs then?

> I have not had the time to think about this.  I will have to take
> some time to add to this.  I will sit down and play with xargs on my
> home machine and see if I can get the hang of it with the various
> things I work with.  I know that I am on the verge of not being able
> to ls and mv files in some directories on my home machine.

Things like "find -type f -print0 | xargs -0 -I{} mv '{}' /somewhere"
are quite handy.  The -print0 and -0 help in working with filenames
that contain spaces.

Have fun.  And definitely post if you have questions.  There are far
smarter people than myself on this list who also enjoy solving command
line riddles.

(Apologies to Steven Orr for butchering any of the xargs examples. ;)

-- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The average woman would rather be beautiful than smart because the
average man can see better than he can think.

Attachment: pgpleBBltX6Kd.pgp
Description: PGP signature


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux