8 # delete trailing whitespace (spaces and tabs)
9 cat file.txt | sed 's/[ \t]*$//'
12 echo "foo bar baz" | sed 's/bar/"&"/'
14 # replace spaces with tabs
17 # replace foo with bar
18 sed -i -e 's/foo/bar/' ~/file.txt
20 # delete lines matching a pattern
21 sed -i -e '/kern/d' /etc/syslog.conf
23 # comment out a line (should anchor)
24 sed -i -e '/^Something.*/#&/g' /tmp/file.txt
26 http://www.grymoire.com/Unix/Sed.html
28 http://www.eng.cam.ac.uk/help/tpl/unix/sed.html
30 http://sed.sourceforge.net/sed1line.txt