[Linux-disciples] xargs -0
Stephen R Laniel
steve at laniels.org
Tue Jul 11 16:04:47 EDT 2006
On Tue, Jul 11, 2006 at 02:54:42PM -0400, Adam Rosi-Kessel wrote:
> grep -Zirl [pattern] [sourcePath] |
> tr "\n" "\0" |
> xargs -0i cp "{}" [destPath]
The trouble with that is: what if the file contains
apostrophes or quotes? Then the '{}' thing will break. E.g.,
(16:03) slaniel at inwalkedbud:~/testdir$ grep -Zirl stuff . |tr '\0' '\n' |xargs -0i cp '{}' ..
cp: cannot stat `./file\'s name contains "" (quotes)\n./file\'s name contains apostrophe\n': No such file or directory
whereas
grep -Zirl stuff . |xargs -0 mv --target-directory=/home/slaniel
works fine.
--
Stephen R. Laniel
steve at laniels.org
Cell: +(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20060711/0d7ad2d6/attachment.pgp
More information about the Linux-disciples
mailing list