I have a script that uses wget and saves the output to a file with a name of an incrementing variable.
Counter.sh:
number=1
for i in $(cat file)
do
wget $i -S -O $number.html 2>&1
((number++))
sleep 1
echo 'done'
done
I can run the script from the command line and it operates perfectly. However when I execute it from within another script:
Script 2:
./counter.sh
I receive the following output:
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
For some reason the counter ++ is not working when executed from within another script. How can I fix this?
((number++))
), e.g. if your default shell isdash
. – fra-san Jan 21 '19 at 22:00#!/bin/bash
as the first line of your script. – Crypteya Jan 21 '19 at 22:09