Dog walker, Geeky sort…

Tag: bash

  • Bash / MySQL queries…

    Reduce connection counts to MySQL by using an array to get many values at once (assuming they’re single ‘word’ values)

  • Avoiding unnecessary commands in bash….

    Some alternative bash things…. ( avoiding unneecessary use of cat / awk / grep …. )

  • Bash random number generation

    Historically I’ve used $RANDOM as a random number source in bash — a bit like : RAND=$(( $RANDOM % 10 )) when I’ve needed a random number out of 0,1,2,3,4,5,6,7,8 and 9 one problem with this is that $RANDOM itself is populated between 0 and 32767 by the shell – so it’s not going to […]

  • Sponge – Shell command

    Today, my sed kung-foo seemed to be lacking, so I ended up having to split the sed command over a zillion lines… Normally I’d do something like : sed ‘s/foo/bar/g’ tmp.txt > tmp2.txt sed ‘s/fo2/blah/g’ tmp2.txt > tmp3.txt But this obviously gets painful after a time, a different approach would be to use sponge where […]