bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: sed --in-place bug (updates mtime of file even if no changes are mad


From: John Vanderpool
Subject: Re: sed --in-place bug (updates mtime of file even if no changes are made)
Date: Mon, 12 Dec 2011 16:28:25 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110921 Thunderbird/3.1.15

On 11/11/11 19:35, Eric Blake wrote:
On 11/08/2011 02:32 PM, John Vanderpool wrote:
--in-place shouldn't update the mtime of the file if the pattern doesn't
match
(i.e. no changes were made to file)
Why not?  Conceptually, 'sed --in-place' is short-hand for 'sed>  temp,
mv temp original', since it is not possible to known a priori whether
the sed script will modify the input when generating the temporary file.

You're welcome to submit a patch if you think you can fix it, but right
now, I don't think sed should have to recognize whether the output is
identical to the input.  If you need mtime unchanged, then use sed to a
temporary file yourself, and compare the two files before deciding
whether to move the temporary file or keep the original.


thanx for your time replying.

My C programming is a little rusty (like 20 years!) so don't think I should
muck with the code.  Possibly a mention in man page would be prudent
though? (see bottom)

here is how this came to light, a very senior SA had the task of changing a
NASA mandated mail list from one name to another and the name was all
over the systems so he ran:

find / -type f -exec sed --in-place 's/address@hidden/address@hidden/' {} \;

and boom, every file on the systems all had the current date - ouch!

----------------------

possible man page change:

       -i[SUFFIX], --in-place[=SUFFIX]

              edit files in place (makes backup if extension supplied)
WARNING: input file's mtime is updated regardless of if sed made any changes or not




reply via email to

[Prev in Thread] Current Thread [Next in Thread]