bash while loop drops last line of text file
bash, loops, while-loop
Solution
Note:
21545a21548
> yheebash-3.00$
^---- no line break
Your file doesn't terminate with a line break.
Problem
when i cat this file I get 6 lines (it is a diff file) ``` bash-3.00$ cat /tmp/voo 18633a18634 > sashabSTP 18634a18636 > sashatSTP 21545a21548 > yheebash-3.00$ ``` however when i read it line by line i only get 5 lines. ``` bash-3.00$ while read line ; do echo $line ; done < /tmp/voo 18633a18634 > sashaSTP 18634a18636 > sashatSTP 21545a21548 ``` or this ``` bash-3.00$ cat /tmp/voo | while read line ; do echo $line ; done 18633a18634 > sashabSTP 18634a18636 > sashatSTP 21545a21548 bash-3.00$ ``` i am missing the last line 'yhee' from the while loops.