Re: trailing blank line in a text file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2004-07-20 at 23:01, Craig White wrote:
> On Tue, 2004-07-20 at 19:25, Robert Locke wrote:
> > On Tue, 2004-07-20 at 21:39, Olga wrote:
> > > No in vi and nano I do not see anything. But in gedit I see the following
> > > (for example)
> > > 
> > > 1 Mike
> > > 2 John
> > > 3 Adam
> > > 4
> > > 
> > > The above is an example of what a file looks like with lines numbered.
> > > (numbers are not actually part of the file). I want the file to be only 3
> > > lines long (as an example); however, what I get is 4 lines where line 4 is
> > > an empty line. I can eliminate only using mc (F4). In nano, vim, vi it is
> > > invisible, but in gedit (gui editor) it shows what I displayed above. I
> > > can backspace after 4, it bring me to Adam, but when I save the file and
> > > reopen it, the output is exactly the same as I am showing now (empty line
> > > 4 stays).
> > > 
> > 
> > Let's try a different approach....
> > 
> > After you save the file in whichever editor, can we confirm that it
> > actually has the "four lines" or really just has "three lines"?
> > 
> > How about running "wc -l filename" and see how many lines it reports... 
> > This will help to confirm for you whether the file truly has the blank
> > line, or is just a visual construct of the editor.
> ----
> You have a classic half full / half empty paradigm going here.
> 
> The point is that a large number of editors will add a LF to the end of
> the file when it saves it. Thus, it doesn't put anything on the '4th'
> line in this example, it only makes sure that line 3 ends with a LF
> character. Whether you want to say that this file has 4 lines or 3 lines
> is really a subjective matter. It definitely has 3 lines, each of them
> ending with a LF character.
> 
> Craig
> 

I'm not sure about the php code being referred to, but a more generic
problem for my understanding....

How does one have a line without an end to the line?  I always assumed
that all lines ended with <LF>, including the last line of the file.... 
I can conjecture the creation of text at the end of the file without a
<LF> at their end, but that to me is not really a line.  I guess I fall
back to more of a read loop, I suppose....

Of course, this is the beauty of Unix/Linux: we can each define as we
see fit.....

--Rob



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux