On Dec 7, 2007 5:49 AM, sancho1980 <[EMAIL PROTECTED]> wrote: > i have a script that reads lines from a file in this manner: > > cat infile | while read line > do > echo "$line" >> outfile > done > > The problem I have occurs whenever there is a whitespace at the end of a > line in the input file, because this whitespace get automatically truncated > from "$line", and i dont want that..i want the whole line to go into > outfile, no matter if the last characters are whitespace!
You do win the coveted "useless use of cat" award, but even with that I can't reproduce your problem here. What version of bash are you using? $ cat -t -E test1 this $ file $ contains some $ extra^I$ whitespace $ $ while read; do echo "$REPLY" >> test2; done < test1 $ cat test1 | while read; do echo "$REPLY" >> test3; done $ l test* -rw-r----- 1 dave dave 51 Dec 7 11:19 test1 -rw-r----- 1 dave dave 51 Dec 7 11:19 test2 -rw-r----- 1 dave dave 51 Dec 7 11:19 test3