Unix sed/awk-fu et al

Extracting data from an XML/HTML node
In this example, you need to extract the data between ... . Replace as needed % echo ' Lorem ipsum dolor sit amet. ' | sed 's/.* \(.*\)<\/p>.*/\1/' Lorem ipsum dolor sit amet.

Extracting an attribute from an XML/HTML node
In this example, src is the attribute that you need. Replace as needed. % echo ' ' | sed 's/.*src=["]\(.*\)["].*/\1/' http://example.org/script.js

Removing carriage return characters (^M) from DOS/Windows files
tr -d \\r &lt; dosfile &gt; newfile

Trimming whitespaces
echo "       foobar      " | sed 's/^space:*\(.*\)space:*$/\1/'

Remove comments and blank lines from configuration files
grep -v -e '^blank:*#' -e '^$' config_file.conf

Determining the parent interface of a cloned wlan device
/sbin/sysctl 'net.wlan.0.%parent' | /usr/bin/sed 's/.*: \(.*\).*/\1/'
 * 1) note: may be applicable to FreeBSD only

Ignore non-matching lines in sed
sed -e 's/.../.../;tx;d;:x' http://stackoverflow.com/a/1665662

Show modifies lines only using diff
diff --unchanged-line-format= --old-line-format= --new-line-format='%L' a b

Remove filename extensions to all files in current directory
for i in `ls *`; do   mv $i ${i%%.*}; done