Mohan Cheema's Online Diary

Site Just to Keep Track of My Day to Day Work.

April 28, 2010
by Mohan Cheema
0 comments

Often Useful often forgotten unix commands

Here I have tried to list the commands that are useful for us (sys admins) but we still tend to forget. Listed here are a bunch of unix commands.

Share
Share

April 28, 2010
by Mohan Cheema
0 comments

SED One Liners

FILE SPACING

  • double space a file
sed G
  • double space a file which already has blank lines in it. Output file should contain no more than one blank line between lines of text.
sed '/^$/d;G'
  • triple space a file
sed 'G;G'
  • undo double-spacing (assumes even-numbered lines are always blank)
sed 'n;d'
  • insert a blank line above every line which matches “regex”
sed '/regex/{x;p;x;}'
  • 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;}'

Share
Share