[H-GEN] Useful not so obvious tips

Anthony Towns aj at azure.humbug.org.au
Tue Oct 26 00:04:55 EDT 2004


On Tue, Oct 26, 2004 at 09:15:33AM +1000, Byron Ellacott wrote:
> Michael Anthon wrote:
> >belial:~# find . -name file\* -print0 -maxdepth 1 | xargs -0 -i ls {}
> >./files.txt
> >./file with spaces
> >Does them one at a time (useful is the program only takes one argument)
> You could also use:
>     find . -type f -printf '"%p" ' | xargs ls

Err, you could also use:

	find . -name file\* -print0 -maxdepth 1 | xargs -0 ls

> If you find 
> you're needing to use the -print0 and -0 options, you probably aren't 
> getting any benefit from xargs anyway.

Using xargs with "-i .. {}" is the killer, not -0. (You might really
want ls -d, if some of the files might be directories. Or "-type f"
in the find command)

What's really sad is that you can't use find as the command for xargs
-- xargs adds the arguments at the end of the command line, and find
requires the path arguments to appear at the beginning. Suck. :(

Cheers,
aj

-- 
Anthony Towns <aj at humbug.org.au> <http://azure.humbug.org.au/~aj/>
Don't assume I speak for anyone but myself. GPG signed mail preferred.

``[S]exual orgies eliminate social tensions and ought to be encouraged.''
      -- US Supreme Court Justice Antonin Scalia (http://tinyurl.com/3kwod)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.humbug.org.au/pipermail/general/attachments/20041026/5654b953/attachment.sig>


More information about the General mailing list