Syntax error in for loop when redirecting output to file in background
You don't need a ;
after a &
, the &
itself acts as a command separator. See the "List of commands" section in the Bash reference manual .
This will execute three concurrent ping
:
ping -c 3 askubuntu.com & ping -c 3 askubuntu.com & ping -c 3 askubuntu.com &
You should place the background command in ()
like this:
for k in {2..3}; do for i in {1..3}; do for j in {1..3}; do (./run_parser.sh ${k} ${i} ${j} > parse_${k}${i}${j}.log 2>&1 &); done; done; done