Skip to main content

Bash loop with End of Line as delimiter

Here is how you do a for loop that uses the end of the line as the delimiter instead of space delimited.
The reason this is better is that you can set variable inside the loop and check them outside unlike doing it with a while read loop.
The file can now have spaces on each line.



for i in `cat testfile.dat`
        echo $i
echo ${CHECK}
Subscribe to Code