Content added Content deleted
imported>mutante mNo edit summary |
imported>DrOwl No edit summary |
||
Line 11:
[http://www.student.northpark.edu/pemente/sed/sed1line.txt HANDY ONE-LINERS FOR SED]
== Inline replace for Solaris==
This is my 5 line backup and in-line replace for Solaris (will work on a lot of other *nix too)
[[Bash_Scripts#Archive_files|archive]] is a nice script use to backup files ;)
<pre>
# for x in $(grep -l kgl-fwall03-eth8 *) ;
do archive $x ; mv $x $x.tmp ;
sed s/kgl-fwall03-eth8/kgl-app-tier-fw-eth8/ $x.tmp > $x ;
rm $x.tmp
done
</pre>
= Man-Page =
<man>sed</man>
|
Revision as of 10:26, 24 July 2009
Beispiele
Alle Zeichen "=F1" und "=F2" in einer Datei durch "X" ersetzten
cat text.txt | sed -r s/"(=F1)|(=F2)"/X/g
oder, um UUOC zu vermeiden:
sed -r s/"(=F1)|(=F2)"/X/g text.txt
Inline replace for Solaris
This is my 5 line backup and in-line replace for Solaris (will work on a lot of other *nix too) archive is a nice script use to backup files ;)
# for x in $(grep -l kgl-fwall03-eth8 *) ; do archive $x ; mv $x $x.tmp ; sed s/kgl-fwall03-eth8/kgl-app-tier-fw-eth8/ $x.tmp > $x ; rm $x.tmp done
Man-Page
<man>sed</man>