At Wed, 17 Sep 2003 11:40:31 +0100, Karsten M. Self wrote: > > on Wed, Sep 17, 2003 at 08:08:26AM +0800, csj ([EMAIL PROTECTED]) wrote:
[...] > > Is there anything intrinsically wrong with: > > > > find directory -name "*.foo" | xargs sed -i -f sed_script > > Well: > > - It outputs everything to stdout, rather than a named file for each > input. I used to think that way too. But since I discovered option -i, sed has replaced ed for most of my recursive search-and-replace operations: aldebaran:~> sed --help | grep -A1 in-place -i[suffix], --in-place[=suffix] edit files in place (makes backup if extension supplied) > - You need to restrict the number of input files with 'xargs -n 1' Why? What happens? I've never used that option myself. Is it a memory-allocation issue? > - You could run into problems with filenames containing embeded IFS > characters. "-print0 / -0" are useful arguments. Yes. > Personally, I'd do it as: > > for f in $( find path -name \*.foo ) > do sed -e 'stuff' < "$f" > "$f.tmp" && mv "$f.tmp" "$f"; done Which I used to do until I discovered option -i. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]