Friday, May 25, 2012

sed command

1. from shell prompt
$> cat test.txt | sed 's/aaa/bb/g;s/cc/ddd/g' > newtest.txt
$>  cat test.txt | sed '1,10s/aaa/bb/g;11,20s/cc/ddd/g' > newtest.txt

2. in VI
:%s/aa/bb/g   #change the whole file
:s/aa/bb/g      #change the current line

reference:
http://lowfatlinux.com/linux-sed.html

1 comment: