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 18:39, Olga wrote:
>> > On Tue, 20 Jul 2004, Alex White wrote:
>> >
>> >> > Can anybody tell me what is going on? Why do I get the trailing
>> blank
>> >> line.
>> >> >
>> >> > Thank you.
>> >> >
>> >> > Olga
>> >>
>> >> What are you using to edit the files in question? I know that
>> >> in FC2 and I think FC1, emacs asks you when you edit a file if
>> >> you want a blank line inserted at the end. Could this be what
>> >            ^^^^^^^^^^^^^^^^^^^^^
>> >> you're seeing?
>> >
>> > Not a blank line, a linefeed at the end of the last line.  vi, on the
>> > other hand, always ends lines with a linefeed.  Some programs that
>> read a
>> > line at a time will break if the last line does not end with a
>> linefeed.
>> >
>> > --
>> > 		Matthew Saltzman
>>
>> 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).
>>
>> What is the difference between a new lien \n and a line feed?
> ----
> in Unix/Linux, a \n is the same as a line feed. Windows terminates lines
> with a CR and Mac has both CR & LF
>
> It is customary for Unix/Linux text files to end with a line feed and
> thus, most editors will simply add one for you.
>
> It seems that the newer versions of emacs offer to add a line feed to
> the end of a text document when you close it if it isn't already there
> (a Y/N question). vi is of course an industrial strength editor and I
> would bet big money that there is a configuration option to turn it off
> - and probably many other editors have that option as well.
>
> Also know that you could probably create a little shell script (and /or
> bash function) to chomp the last LF from a file - info bash (look at
> chomp)
>
> Craig
>
Thank you for the explanation. What you wrote makes a lot of sense. I will
investigate the options you mentioned.



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

  Powered by Linux