January 2009
5 posts
Saving a couple idioms
Things I’ve written down from articles lately, don’t want to lose them: Nice awk example (count number of users of each shell): awk -F: '{x[$7]+=1} END {for(z in x) {print z, x[z]}}' /etc/passwd Nonobvious (to dumb me, at least) use of slicing in Python: def reverse(str): return str[::-1] print reverse('Bite me') Using fileinput Python module: import fileinput for line...
Jan 30th
From Linux Journal letters, a nice way to use text in compressed files without needing to know they’re compressed, or what they’re compress with… function do_cat() { local CAT CAT=cat case "$1" in *.gz) CAT=zcat;; *.bz2) CAT=bzcat;; esac ${CAT} "$1" } function smart_cat() { local i for i in "$@"; do do_cat "$i" done } ...
Jan 27th
"Stealth" error messages
Weird but true: If your Linux disk is full, your XWin-32-based PC xterms won’t connect, complaining of an “authentication error.”
Jan 5th
netstat -tpe
From Linux magazine sidebar, nice set of switches for netstat: netstat -tpe t limits to TCP, p lists PID, and e gives some nice extra stuff (sendq, recvq, username, inode, foreign address looked up via DNS, program name) You need to be root for some of these to appear. This is my new favorite invocation of netstat (I used to use -anp routinely).
Jan 5th
Oldest file (of my own) in my home directory
If I’m pretending to be a blogger, I should jump on a meme or two. Here’s one (find and post the oldest file in your home directory): http://rhodesmill.org/brandon/2009/new-years-meme/ Not much earthshaking to find, because I change computers pretty often. This was in a backup from a prior computer: 2002-03-26 ./backups/dhancock_old_dev/oracle/schemas/save/reserved28/xmlrpc.py ...
Jan 2nd