on Tue, Jan 09, 2001 at 08:30:59PM -0500, Jonathan D. Proulx (jon@ai.mit.edu) wrote: > On Tue, Jan 09, 2001 at 11:29:31AM -0800, kmself@ix.netcom.com wrote: > :on Tue, Jan 09, 2001 at 08:20:18AM -0500, Jonathan D. Proulx (jon@ai.mit.edu) wrote: > > :> find . -name *.txt -exec cp {} {}.tmp \; -exec sed s/foo/boo/g {} \; > :> > :> or writing a small shell/perl/sed/awk/whatever script that take the > :> original file as input ad -exec'ing that. > : > :Still doesn't work -- sed doesn't change files in place, it reads from > :file and writes to stdout. > > You've been on this list a little while if I recall, and I suspec > could reason out the solution to the problem, given that you know sed > reads from a file and writes to stdout. So why not provide the > obvious answer, rather than just point out the bug? > > find . -name '*.txt' -exec cp {} {}.tmp \; -exec sed s/foo/boo/g {}.tmp > > {} \; I'd tried something similar to that, briefly, and noted that the second brace wasn't being expanded properly. My usual approach in modifying a long list of files, as in this instance, is to generate a short, one-off shell script. Somewhat pedantic, but it works. Using editing and piped shell functions from within vi makes creating the script relatively painless. It's usually possible to check syntax prior to committing the results as well, which can be helpful. -- Karsten M. Self <kmself@ix.netcom.com> http://kmself.home.netcom.com/ What part of "Gestalt" don't you understand? There is no K5 cabal http://gestalt-system.sourceforge.net/ http://www.kuro5hin.org
Attachment:
pgpHHBdW0SlRb.pgp
Description: PGP signature