I'll let the code do the talking; here's the basic bash script (stored as an executable):
#!/bin/bash if [[ $# -ne 1 ]]; then echo "Usage: cat commands.txt | $(basename $0) <num processes>" exit 1 fi (while read line; do echo -e "$((++i)):\n\t$line"; done; echo "all:" $(seq 1 $i)) | make -B -j $1 -f <(cat -) allThis uses a couple of clever tricks. I especially like the use of process substitution in the make command (substituting the 'cat -' for the input makefile).
This approach allows the commands in commands.txt to redirect their own output as they need to (using '>', '2>', '&>', etc.)
No comments:
Post a Comment