I have created a shell script below that checks whether the file out.txt contains any line with the text "Billing_20160210". I am getting the error in the regular expression part which states that "[[: not found". Not sure whether i am missing something. Any help would be appreciated.
#!/bin/bash
bq ls test:Dataset_test > out.txt
cat out.txt | while read LINE
do
if [ LINE = *"Billing_20160210"* ];
then
echo "Processing $LINE"
fi
done
Edit not working:
#!/bin/bash
bq ls geotab-bigdata-test:JS_test > out.txt
cat out.txt | while read LINE
do
if [[ $LINE == *"DailyBillingTest_20160210"* ]];
then
echo "Processing $LINE"
fi
done
[ LINE = *"Billing_20160210"* ]with[[ $LINE == *"Billing_20160210"* ]][[: not foundalso implies that you aren't actually using bash as your interpreter to run this script. Are you invoking it withsh yourscript? If so, that would override the#!/bin/bashshebang. If invoking with an explicit interpreter, that needs to bebash yourscript, notsh yourscript..shextension falsely implies thatshcan be used to run a script, which is simply untrue if it's a bash script [hence your bug here], and using an extension at all means you need to either change your callers to invoke the script differently or have its name be inaccurate if you rewrite it in a different language. You don't runls.elf; why would you use extensions on other commands you write yourself?)