Here's a cool way to remove "all but the first tag" of a line, in vi: :s/\([^^]\)<[^<]*>/\1/g Here's a cool way to split the header from the body of an e-mail, and save them in seperate files: sed -e '1,/^$/w 'foo -e '/^$/,$w 'bar Moving on to actual sed programming, join each line with the next line, modify that to look like CSV, then delete the next lines: sed -e '/2007/{h; N; s/\n/,/g; s/ Total files:[[:space:]]//}' -e '/Total/d' Set time accurately to utcnist.colorado.edu on a windows machine: net time /setsntp:128.138.140.44 Perl to un-URL-encode test: perl -ne 's/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge Modern days: use URI::Escape; $bar=uri_unescape($foo); 20:16 < Norby> mysql> select id, color, style, `style group`, (IFNULL(`style group`,style)) as Style2 from `inventory` WHERE 1 LIMIT 0,2; 20:16 < Norby> +------+-----------+----------+-------------+----------+ 20:16 < Norby> | id | color | style | style group | Style2 | 20:16 < Norby> +------+-----------+----------+-------------+----------+ 20:16 < Norby> | 1000 | Blue | Plaid | Woven | Woven | 20:16 < Norby> | 1001 | Sassafras | Cascadia | NULL | Cascadia | 20:16 < Norby> +------+-----------+----------+-------------+----------+ Emacs show CVS diff of current buffer: C-x v = Emacs show CVS diff of directory: M-x cvs-examin /path/to/work/dir From Jim Dennis, illustrating good use of sh builtins: ps wax | while read pid x x x cmd args; do [ $cmd = foo ] && kill $pid; done Using perl to split on non-whitespace lists: echo -n "a,b,c" | perl -anF, -e '{foreach $i (@F) {print "$i\n" ; }}' How to get grep to NOT show up when grepping ps output: ps auxww | grep "[f]oo" or better yet: ps auxww | awk '/pattern/ && !/awk/ {print}' Continuously kill any process with a port in a port range, till none left: lsof -t +r -b -P -i :8200-8299 | awk '/^[0-9]/ {system("echo kill " $1)}' Remove yesterday's file, above a specific size, with no errors: sudo forallnode k1-k9 "find /e/c/k/hadoop/run2/log -mtime 1 -size +1024000k -print0 | xargs -0r rm" Python's "for x in ar" is "if grep {$_ eq "foo"} @array;" in perl getrusage(2) is a system call for a process to find out about its own resource utilization. Perl in-place editing: perl -ni.2004-02-03 -e \"if (!/^dkim:/ && !/^bayard:/ && !/^tarnold:/) {print;}\" /etc/passwd ; if [ -x /usr/sbin/pwconv ] ; then /usr/sbin/pwconv ; fi" Quick perl truncation (I don't know of a way to do this with sed?): perl -pe 'chomp; $_=substr($_,0,25)."\n"' python: python -c 'import sys; print sys.stdin.readline().rstrip("\r\n ")[:25], "\n"' Use awk to make pairs of every 40th host: list-hosts | awk '0 == NR%40 {print}' | awk '{getline n; print "ssh -n", $1, "ping -c 25 -n -q", n, ">! "$1"-"n".ping &"}'