[lug] Appending a file to files

Michael J. Pedersen marvin at keepthetouch.org
Tue Jan 16 08:34:56 MST 2001


On Tue, Jan 16, 2001 at 08:23:58AM -0700, Glenn Murray wrote:
> I want to append the file foo to all the files in
> the bar directory tree.  Why doesn't this work?
> 
> find bar -exec cat foo >> {} \;
> 
> What does work? 

The reason this fails is that the >> is considered part of the shell command,
not part of the find command, nor even part of the exec. You should prolly
have a file named {} in your directory (bar) by now. The way to prevent the
shell from looking at it is actually very easy: eascape those characters. You
can do this in one of two ways:

find bar -type f -exec cat foo \>\> {} \;

find bar -type f -exec cat foo '>>' {} \;

The first is the more likely to work (sorry, these are both untested, but
should both work). You'll notice the '-type f' parameter. This is because if
you don't have that, but do have a subdirectory under bar, it will try to cat
the file foo as an append onto the subdirectory, which will fail. The '-type
'f will tell it to only do this with files.

Hope that helps!

-- 
Michael J. Pedersen
My GnuPG KeyID: 4E724A60        My Public Key Available At: wwwkeys.pgp.net
My GnuPG Key Fingerprint: C31C 7E90 5992 9E5E 9A02 233D D8DD 985E 4E72 4A60
GnuPG available at http://www.gnupg.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20010116/472bc34b/attachment.pgp>


More information about the LUG mailing list