I have a csv file produced with Python that has the following structure:
Name1,8
Name2,0
I want to extract the index associated to each name and to do so I am using one of the two following methods:
line=`grep "Name1" names.csv | cut -d',' -f2`
line=$(grep "Name1" names.csv | cut -d',' -f2)
echo $line #8
But I'm getting an error once I try to implement the comparison:
if [[ ${line} == 8 ]]; then echo TRUE; else echo FALSE; fi
if [ ${line} == 8 ]; then echo TRUE; else echo FALSE; fi
#FALSE
if [ ${line} -gt 8 ]; then echo TRUE; else echo FALSE; fi
: integer expression expected
Someone knows which is the source of this error and how to effectively retrieve a number from a file for latter comparison?