So I have a file that has two lines in it. Both lines contain a number. I want to check if that number is a 0 or not and then echo it out if it is. However bash doesn't let me use the "-eq" operator and tells me the "integer expression expected" error.
I have tried using an array and then a for loop and if statement to loop through the values but it didnt work.
I have also tried using a while loop and loop through the lines in the file but got the same error.
Using string comparisons doesn't seem to work as it doesn't recognise the 0. So I would like to convert the strings to numbers if possible. Can someone advise please.
for i in `cat num.out`;do if [ "$i" -eq 0 ];then echo $i;fi;done
The file num.out contains two lines:
cat num.out
0
0
The file num.out was compiled using the parsed output of another internal company script
Per request:
cat -v num.out
^[[31m^[[1m0^[[0m
^[[31m^[[1m0^[[0m
hexdump -C num.out
00000000 1b 5b 33 31 6d 1b 5b 31 6d 30 1b 5b 30 6d 0a 1b |.[31m.[1m0.[0m..|
00000010 5b 33 31 6d 1b 5b 31 6d 30 1b 5b 30 6d 0a |[31m.[1m0.[0m.|
0000001e```