Quote:
Originally Posted by
RavinderSingh13
GNU sed is having -i.bak option too, which takes backup of Input_file before editing it in-place
First: I haven't known that, so thank you for teaching me something new.
The point was not that it takes or takes not a backup, that it changes or doesn't change the inode (as MadeInGermany mentioned - thank you for providing a way to circumvent that too, should the need arise), though. It should be worth noting, though, that using a
mv within filesystem boundaries is faster than
cp. Across filesystems
mv and
cp are probably equally fast.
For me the main point is portability. I can choose between using the POSIX-way of doing things and that works on all systems and using the GNU-way and that works on less than all systems. For the same reason i would rather hesitate to use a feature in the POSIX-standard which i know would not work (or work differently) on GNU. This is not limited to
sed options or something particular at all. The same goes for anything else i do on a UNIX (or Linux) system.
The second reason i would not suggest to use
-i is NOT, that it rolls some usually necessary actions into one: i talked about not preserving the inode or filemode or owner, but it won't always matter if they are being preserved or not. The point is it
makes it look like it would be the same file
while it is not. One can do everything and anything but one: lie to your users. If you do something, whatever it is, do it - but don't pretend you do something else.
bakunin