[CLUE-Tech] xargs

Kevin Fenzi kevin at scrye.com
Sun Jan 5 19:54:21 MST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>>>> "marcus" == marcus hall <marcus at tuells.org> writes:

marcus> Yes, I recall the issue, and thinking at the time that xargs
marcus> was broken.  I don't dispute that some versions of xargs do
marcus> that, but I do assert that those that do are broken.  In fact,
marcus> xargs on RH8.0 (GNU xargs) *is* one of the broken xargs.  To
marcus> test, execute:

marcus> 	echo "it's a test" | xargs ls

marcus> You *should* get ls complaining about "it's" "a" and "test"
marcus> not being found (unless they actually do exist), but I get the
marcus> same "xargs: unmatched single quote" error message.

marcus> There's nothing really illegal about having a file name
marcus> containing shell meta-characters, and shell scripts are
marcus> supposed to be able to be written carefully enough to not mind
marcus> it, but this behavior of xargs breaks the "find ... | xargs"
marcus> idiom and there's no way that I see to get it to work if there
marcus> are any files that contain meta-characters.  That's why I
marcus> contend that it is wrong behavior.

It's worth noting the -print0 argument for find and the xargs -0
argument. That makes them use a null to terminate filenames instead of
white space... 

so: 

find /whatever -print0 | xargs -0 ls 
will work on even files with strange embeded characters. 

see the find and xargs man page for more.

marcus> marcus hall marcus at tuells.org

kevin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.6 and Gnu Privacy Guard <http://www.gnupg.org/>

iD8DBQE+GO/g3imCezTjY0ERAo64AJ98LHqz7rr7PjYib9QX9kzoOej8hACgmB2w
5pEcbNC4iLRM5ypQHoEKiHI=
=QNvq
-----END PGP SIGNATURE-----



More information about the clue-tech mailing list