1984 – the techblog

(Hopefully) useful various sysadmin and other stuff.


Bash: Handling various versions of wc

I really love the wc tool. For those who don’t know it, it sim­ply counts words, lines, char­ac­ters and bytes of any input it receives on STDIN. You’d be sur­prised how often one needs this func­tion­al­ity! But, as with many things POSIX/UNIX, there are dif­fer­ent flavours avail­able; while many tools have the same name on all […]

Self-extracting shell scripts

Recently at work, I had to fig­ure out on how to trans­fer some data to sys­tems used by scripts that were exe­cuted directly on the hosts. It wasn’t that much pay­load, and I really didn’t want to be both­ered to set up a sep­a­rate filesys­tem place where to hosts rsync the data from, make sure […]

Bash: Preparing and executing commands in a variable/string

When writ­ing some shell scripts, one does often have command’s argu­ments and options pre­pared in a vari­able. Aside from the usual quo­ta­tion rules, this usu­ally works fine: > cmd=“ls –a” > $cmd . .. dir1 dir2 dir3 file1 file2 Don’t do this any­more. It only works eas­ily for sim­ple com­mands. As soon as you’ve got more complex […]