Wednesday, April 6, 2011

bash-fu: seq

so on my local cluster I have 9 nodes, and every now and then I need to clean up the mess that my SGE jobs create, or collect the logs or whatsoever. So I want to ssh and execute the same command on each machine. the node names are 'compute-0-[0-9]+'.

enter seq. seq will generate a sequence of numbers in the given range. Using the xargs, I write
seq 1 9 | xargs -L1 -Ix sh -c "ssh compute-0-x ' do something awesome'".

magic is easy :)

No comments:

Post a Comment