

Sed(1) one-liners - adamo
http://sed.sourceforge.net/sed1line.txt

======
rdtsc
I don't see any use of the 'in-place' -i option.

My most useful one-liner:

    
    
            sed -i "s/pat/rep/g"   file
     

It means replace in-place all matches of pat with rep in file.

To make a backup of old file use -i.bak instead of -i where .bak would be the
suffix of the backup file.

~~~
pkrumins
Option -i is not defined in POSIX sed. That's probably the reason author
didn't include it in his list.

I have heard that it's GNU sed option only. (But can't currently say if it's
100% true.)

~~~
silentbicycle
There's no reason why this functionality should be in sed when it can be
implemented on its own and re-used. IIRC there's an an example script to for
that in _The Unix Programming Environment_. Better to use sudo than have
everything implement its own sudo-like functionality, etc.

See "UNIX Style, or cat -v Considered Harmful" by Rob Pike
(<http://harmful.cat-v.org/cat-v/>) for a longer discussion of this.

~~~
imurray
In place operations have been implemented as a standalone utility: sponge from
moreutils.

    
    
        sed 's/blah/foo/' file | sponge file

~~~
wendroid
The irony

s stands for stream

there is no s in ed

------
pkrumins
* explained [http://www.catonmat.net/blog/sed-one-liners-explained-part-o...](http://www.catonmat.net/blog/sed-one-liners-explained-part-one/)

:)

