So I want my script to test for the existence of a file which I already populated with numbers. It does that, but after it does that I want it to run a while look checking to see if the numbers in the file are either odd or even as it checks each number on each line. For all I know my script structure is bad, but the code I have below does not produce a desired result.exist=rnddata.txtif [ -f $exist ]; then echo file exist processingelse echo file does not existexit1fiwhile read existdoif [ $((exist % 2)) -eq 0 ]; then echo evenelseecho oddfidoneexit
Help with script reading numbers from a file and determining if they are even or odd numbers
shell;shell script;test;arithmetic
Try this:while read numberdo    if [ $((number % 2)) -eq 0 ]; then         echo even    else            echo odd     fi      done < $existread reads into variables on it's command line.  So you have to feed the file data into the loop so read can get it.  Here we do that with the < $exist after the done of the while loop.The read command doesn't have a manpage because it's a shell builtin.  To see how it works, type man sh (hint, search for readonly because that's a lot easier to find.)