HI ,
I have to check the values of variable is blank or not.
exm :
###test
test1
var=`cate filename | head -1 | cut -c1-3`
I need to check the first three character of 1st line . if it is blank .then exit or we need to process .
Thanks in advance .
Something like the following should work
if [[ -z $var ]]
then
echo "Empty var"
exit 1
fi
unrelated but I would suggest changing the
var=`cate filename | head -1 | cut -c1-3`
line to
var=`head -1 filename| cut -c1-3`
There is no reason to read the entire file when you only need the first line.