admin
20 July 2009
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 testfile.data file can now have spaces on each line.
#!/bin/sh IFS=" " for i in `cat testfile.dat` do CHECK="test" echo $i done echo ${CHECK}
Category
- Log in to post comments