...
Code Block | ||
---|---|---|
| ||
lineNo=10 while IFS= read line; do echo "Line $lineNo: '$line'" lineNo=$(( lineNo + 1 )) done < sampleinfo.txt echo -e "\nRead $lineNo lines" |
- The IFS= clears all of read's default input field separators (whitespace).
- This is needed so that read will set the line variable to exactly the contents of the input line, and not strip leading whitespace from it.
- Note the odd syntax for incrementing the line number variable.
...