I am making a bash script. the objective is:
execute a program wait some seconds reset the program and repeat the process.
I make 2 scripts but i don’t know where is the error…
#!/bin/bash
while true;
do
seg=`date +%M`;
if [[ "$seg" -eq "30" ]];
then killall sox;
echo "reset";
fi
done
bash: error sintáctico cerca del elemento inesperado `;’
#!/bin/bash
while true;
do
nice -n-10 sox -q -V0 --multi-threaded -t alsa hw:2,0 -t alsa pcm.default &&
done
bash: error sintáctico cerca del elemento inesperado `done’
Issues with Script #1:
The
;notation is to run multiple commands on the same line, one after another. Bash syntax requires thatwhileanddoon separate lines (same withif ...andthen, and separated by;if on the same line. Command statements are not normally terminated with a;char in bash.Change your code from:
To:
Issues with Script #2:
&means to run the command as a background process.&&is used for conditional command chaining, as in: “If the previous command before&&succeeds, then run the next command after the&&“Change from:
To: