Monday, October 29, 2007

sed examples

Get the last node from a path:
$ pwd
/cygdrive/c/cygwin/var/log

$ pwd | sed -e "s/.*\///g"
log

Display file without the blank lines and remove the first line:
$ cat bearish.htm | sed -e '/^ *$/d;1,1d'

Remove first 3 lines in a file:
$cat bearish.htm | sed -e '1,3d'

Remove HTML tags:
$cat bearish.htm | sed -e 's/<[^>]*>//g'

No comments: