I have a file that reads something like:
500 text1 text1 text1 text1 text1 text1 (200)
200 text2 text2 text2 text2 text2 text2
350 text3 text3 text3 text3 text3 text3
400 text4 text4 text4 text4 text4 text4 (300)
if [ -f file.txt ]
then
echo "Input your number:"
read number
if [ $number -ge 200 ] && [ $number -le 400 ]
then
echo "The number that matched the file are:"
awk $1 >= 200 && $8 <= 400 {print} numbers.txt
else
echo "Number must be between 200 and 400."
fi
Trying to extract numbers between 200 and 400 and then print the whole line and I just keep getting the while file as output instead
change the
awkline touse
substrto extract the number from the paranthesized expression and the added number of fields check will avoid false matches when there is no 8th field.