[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sed, bash script



on Wed, Sep 17, 2003 at 02:44:09PM +0200, Matthias Czapla (dermatsch@gmx.de) wrote:
> On Wed, Sep 17, 2003 at 11:40:31AM +0100, Karsten M. Self wrote:

> > 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
> 
> And what if a file named $f.tmp already exists? Unlikely, but possible.

Generally, I manually check for that first, and am working on a
controlled subdirectory in which I don't encounter that problem.

Ideally, you'd script this more rigorously and use tempfile to create a
unique, secure, temporary file.

Peace.

-- 
Karsten M. Self <kmself@ix.netcom.com>        http://kmself.home.netcom.com/
 What Part of "Gestalt" don't you understand?
    Americans [...] need to watch what they say.
    -- Ari Fleischer, White House Press Secretary
       http://www.whitehouse.gov/news/releases/2001/09/20010926-5.html

Attachment: pgpJn5ic0lZKs.pgp
Description: PGP signature


Reply to: