Why can't I run two commands within a single line bash loop?
$ for i in {1..100} do printf %s "$(date)" ; mysql -uroot -e "SHOW SLAVE STATUS\G" | grep "Seconds_Behind_Master" ; sleep 10 ; done
-bash: syntax error near unexpected token `mysql'
But this simple version works:
for i in {1..3}; do echo $i ; ls ; done
You need a ;
after your brace expansion. You have it in the simple example, but not in the "broken" one:
for i in {1..100}; do printf %s "$(date)" ; mysql -uroot -e "SHOW SLAVE STATUS\G" | grep "Seconds_Behind_Master" ; sleep 10 ; done
^ this one
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With