Computing.Net > Forums > Unix > ksh reading from file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

ksh reading from file

Reply to Message Icon

Name: coop
Date: June 23, 2005 at 08:08:03 Pacific
OS: XP
CPU/Ram: 2Gighrtz Pentium 4/512mb
Comment:

Hi
I'm reading from a file using a while loop, but if my file does not end with a new line, the last line is not read. My script is basically:

while read -r line
do
...
done < $filename

Is there anyway to read the last line if the file doesn't end with a newline character?

Thanks
Coop



Sponsored Link
Ads by Google

Response Number 1
Name: coop
Date: June 23, 2005 at 08:29:22 Pacific
Reply:

Hi
I actually ended up just adding a newline character to the end of the file with:

echo >> filename

I should've checked the forums earlier

Thanks


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: ksh reading from file

Read win file from Unix pl_sql www.computing.net/answers/unix/read-win-file-from-unix-plsql/5994.html

Writing to/reading from 3, 4 etc. www.computing.net/answers/unix/writing-toreading-from-3-4-etc/7388.html

reading from a file in unix www.computing.net/answers/unix/reading-from-a-file-in-unix/7355.html