Eric Irrgang wrote:

On Mon, 21 Jun 2004, Doc Shipley wrote:


William L. Jarrold wrote:

...any idea how to avoid that "Argument list too long"
error?  I have been meaning to send a separate note about
that problem for weeks now....Recent hacks have
suggested that something like this might work...

for i in ls ; do cp $i <cd-rom-incantation> ; done

...but a non-hack solution would be greatly appreciated.  My perl
is worse than my unix but I am v willing to try a perl soln but you'll
have to be pretty explicit about what I am to do.

man xargs

 /bin/ls * | xargs -J % cp -rp % destdir

Should do about what you want.


That * will still expand to an argument list that is too long.  Any reason
not to use 'find ./'?  I think OS X supports the -maxdepth flag if you
don't want to recurse directories.  Also, there's the '-ls' flag if you
want to get an ls -l without using globbing or piping to xargs.

The example is from the xargs man page, less the directory treatment and character list:


        /bin/ls -1d [A-Z]* | xargs -J % cp -rp % destdir

xargs also allows limiting the number of arguments passed to the utility (cp in this case) to keep from exceeding the line-length limit.

I'd probably use find myself, but was answering a little too literally; not how best to copy the files. :\

By the way, if you admin RedHat systems post-v7.0 and haven't noticed yet, you really need to test the above ls command with that set of regular expressions. The results are surprising and potentially dangerous.

Also, could you guys trim your recipient list? This thread threatens to snowball.

  I *hate* this broken-assed reply-to crap.


Doc _______________________________________________ Siglinux mailing list [EMAIL PROTECTED] http://machito.utacm.org/mailman/listinfo/siglinux

Reply via email to