samedi 20 décembre 2014

Cant compare strings in bash

I have written code:



empty=""
while read line
do
if [ "$empty" == "$line" ] ; then
echo "Empty line!!"
fi
done


I run it using



sh checkEmptyLine.sh < input.txt


But I am getting the error as follows:



checkEmptyLine.sh: 4: [: unexpected operator


Please let me know where have I gone wrong


PS I have tried [[ ]], "${line}", and they are not working for me..


Thanks in advance :)


Aucun commentaire:

Enregistrer un commentaire