[Nottingham] Shell programming

Graeme Fowler graeme at graemef.net
Sun Dec 19 11:56:55 GMT 2004


Howdy

On 18 Dec 2004, at 15:03, Martin wrote:
> tail -f some.log.file

[someprompt ~]# tail -f /var/log/1 /var/log/2 ... /var/log/lots

Parking a tail on multiple logs is often useful, as it allows (for 
example) you to see both accesses and errors being generated by an 
Apache server in the same terminal. Saves on screen real estate :)

The one thing I've found most useful in the last twelve months is 
getting a proper understanding of escaping shell metacharacters - 
especially in the case where you're using "passwordless" logins to 
remote machines in a round-robin way, but need to pass commands and 
variables across the session. Getting a hold of the difference between:

ssh user at server "echo $HOME"
and
ssh user at server "echo \$HOME"

is tremendously useful :)

I've also found myself becoming terribly fond of complicated plumbing 
when processing things like netflow data:

for y in 03 04 05; do for x in 00 05 10 15 20 25 30 35 40 45 50 55; do 
echo $y$x; flow-cat 
/var/flows/2004/2004-12/2004-12-15/ft-v05.2004-12-15.$y$x*| 
flow-nfilter -f flow.def -F $TARGET | flow-stat -f9 -S2 |head -22 | 
grep -v ^# | awk '{ x=sprintf("%.2e",($3*8/(300))); 
y=sprintf("%.2d",($4/300));  print $1 "              " x " bits/sec     
      " y " packets/sec" }'; echo; done; done

Ugh. That's really ugly - I should really, really write a wrapper to do 
that lot for me!

Graeme




More information about the Nottingham mailing list