I am writing a bash-script for stress testing on a CPU. The script should take readings of different cpu-methods while changing the number of cpu-workers. The script itself looks like this:
WORKERS_START=1
WORKERS_END=6
TARGET=$1
if [ -z $TARGET ]
then
echo "Pass target cpu method"
else
echo "Analize $TARGET"
for i in $(seq $WORKERS_START $WORKERS_END)
do
echo -e "\nstart $i worker(s)\n"
stress-ng --cpu $i --cpu-method $TARGET -t 15s --metrics | sar 1 10 -u
done
fi
But when I run it on my Ubuntu server I get the following error:
joulin@matthewserver:~$ bash cpu_bench.sh gcd
cpu_bench.sh: line 4: $'\r': command not found
cpu_bench.sh: line 11: syntax error near unexpected token `$'do\r''
'pu_bench.sh: line 11: ` do
However, when I run it on a local machine, everything works fine. I don’t understand where the error comes from and I'll be glad if you can help me with this problem.