Protagonists
- The Admin
- Pipes
- The Cron Daemon
- A bunch of text processing utilities
- netstat
>>
the Scribe
Setting
The Cron Daemon is repeatedly performing the same job where he forces an innocent netstat
to show the network status (netstat -n
). Pipes then have to pick up the information and deliver it to bystanding text processing utilities (| grep tcp | awk '{ print $5 }' | cut -d "." -f-4
). >>
has to scribe the important results to a file. As his highness, The Admin, is a lazy and easily annoyed ruler, >>
only wants to scribe new information to the file.
*/1 * * * * netstat -n | grep tcp | awk '{ print $5 }' | cut -d "." -f-4 >> /tmp/file
Soliloquy by >>
To append, or not append, that is the question:
Whether 'tis new information to bother The Admin with
and earn an outrageous Fortune,
Or to take Arms against `netstat` and the others,
And by opposing, ignore them? To die: to sleep;
note by the publisher: For all those that had problems understanding Hamlet, like I did, the question is, how do I check if the string is already included in the file and if not, append it to the file?