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

1 comment:

Unknown said...

It was very nice article and it is very useful to Linux learners.We also provide Linux online training

 

Blogger news

Blogroll