'if statement returning [[: not found
I'm writing a dinky little script and I need to do a check on values.
size is going to be a float, or number with decimal point for example like 28.0.
For some reason whenever I run, I get this error:
while read -r line;
do
sample=$(echo $line | awk 'BEGIN{FS="/"}; {print $5}')
size=$(aws s3 ls --summarize --human-readable $line | grep "Total Size:" | awk 'BEGIN{FS=" "}; {print $3}')
# aws s3 cp $line ./crams/
if [[ $( echo "${size} < 20" | bc ) -eq 1 ]]; then
echo "${sample}\t${size}"
fi
done < $1
download-aws.sh: 6: download-aws.sh: [[: not found
Any thoughts???
Also if you know of a better way to do the comparison of a float to a int... that'd be great!
Thanks
EDIT:
So I found a solution, I changed the if statement to:
if [ $( echo "${size} < 20" | bc ) -eq 1 ]; then
If anyone could point me in the direction of some awesome explanations of the logic behind the brackets etc... that'd be amazing!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
