Showing posts with label sed. Show all posts
Showing posts with label sed. Show all posts

Monday, April 28, 2008

Remove empty lines with Sed

cat file.txt | sed '/^$/d'

Sunday, April 6, 2008

Sed, Grep, Awk Tutorials

Pattern matching with sed

My intention was to catch the blue part ::

[[tag_open]] href="blah%20blah.mp3">blah blah.mp3 [[tag_close]]

The following sed one liner does it perfectly ;) ...

wget -q -O - http://192.168.0.5:8000/ | grep mp3 | sed 's/.*href="\(.*\)".*/\1/'

The \( , \) and \1 are the key. The \1 prints that what is found between the \( and \).

another possible way is : grep -o PATTERN
another ... : awk -FS 'href=' :-p

Friday, March 14, 2008

Remove weird whitespaces with Sed


cat file.txt | sed -c 's/[[:cntrl:]]//g'

Sunday, March 9, 2008

Remove leading & trailing spaces with sed

Both Leading & Trailing spaces:

sed -e '/^$/d'

Trailing spaces only:

sed 's/[[:blank:]]*$//g'

Thursday, March 6, 2008

Kill html tags with Sed

Link:

cat file.txt | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba'