Showing posts with label use of sed in unix. Show all posts
Showing posts with label use of sed in unix. Show all posts

Sunday, February 14, 2010

use sed when ....

# insert a blank line above every line which matches "regex"
sed '/regex/{x;p;x;}' OR
sed '/regex/{x;G;}'

# insert a blank line below every line which matches "regex"
sed '/regex/G'

# insert a blank line above and below every line which matches "regex"
sed '/regex/{x;p;x;G;}'


# remove the header of a file
sed '/1,1d' filename