Monday, September 13, 2010

sed one-liners

To select a the portion between two keywords

sed -n '/word1/,/word2/p'

selectes the text between word1 and word2 and prints them. Nothing is printed on-screen if the "p" is omitted.

To select the inverse of that or to delete those lines between word1 and word2use "!p".


sed -n '/word1/,/word2/!p'


Also see : http://www.catonmat.net/blog/sed-one-liners-explained-part-three/

No comments:

Print chess board in command line

The following bash one-liner will print a chess board in a terminal (the script works for the shells bash and ksh only) for (( i = 1; i ...