Afficher un message
Vieux 18/08/2006, 17h34   #5
William
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: "read line" ignoring last line

"Anoop" <anoopkumarv@gmail.com> wrote in message
news:1155912577.327410.285380@75g2000cwc.googlegro ups.com...
> Hi All,
>
> I am facing a wierd problem. I have about a 100 shell scripts all coded
> in a similar fashion. All of them read from some file(s) and process
> the data.
>
> But there is this one script which reads from a small file which has
> only 2 lines of data. What happens (and happens only for this script)
> is that only the first line is read, and the last line is ignored
> completely. I do not get any errors.


As Bill Marcum suggested, the problem is in the file, not the
script. I can reproduce your problem by creating a file whose
last line does not have a newline character at the end (read
is looking for this character, cat doesn't care). A newline
tells read it has a full line in the buffer and it's time to
copy it to your variable, but it's hitting the end of the file
before that happens, so...

-Wm



  Réponse avec citation
 
Page generated in 0,04225 seconds with 9 queries