[Ilugc] sed - explanation required

  • From: gopal@xxxxxxxxxxxxxxxxx (Gopalarathnam Venkatesan)
  • Date: Thu Aug 17 13:00:23 2006

Ashok Antony wrote:

hi all,

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

what is the use of 'x' and 'p' there. could any one explain me better ?



Read sed(1).
- p is for printing the output, used in conjunction with -n command line 
option.
- x is for swapping pattern and hold space.

-- 
Gopalarathnam Venkatesan

http://gopalarathnam.com/

Other related posts: