[H-GEN] Useful not so obvious tips
Anthony Towns
aj at azure.humbug.org.au
Tue Oct 26 12:49:08 EDT 2004
On Tue, Oct 26, 2004 at 08:08:18PM +1000, Michael Anthon wrote:
> I don't believe either of these incantations produce the same result as
> the original command. I understand that there is no benefit to using it
> for the ls command but I was simply using that as a trivial example of
> the effect of the -i option to xargs.
Yeah. I don't care for the xargs -i option usually; for find, might as
well just use the -exec ... {} .. \; option and for other things it's
not much better than using a while loop, a la:
cat foo.txt | while read a; do
ls -d "$a"
done
which gives you a bit more flexibility, too. Can get slow though --
shell loops just aren't real fast. For me, though, the only point to
using xargs is to avoid multiple invocations of "ls".
> BUT, instead of, say doing "find blah | xargs -i rm -rf" I
> will do "find blah | xargs -i echo rm -rf". [...] When I'm happy with that,
> rather than go remove the echo I simply add "| sh" onto the end.
Interesting. You're relying on not having files with spaces in the names,
though, which you wouldn't be necessary if you just got rid of the echo
instead. Well, assuming you added the {} to match the -i anyway.
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/20041027/4372e12b/attachment.sig>
More information about the General
mailing list