trailing blank line in a text file

Olga olga at urbantimes.net
Wed Jul 21 02:30:52 UTC 2004


> 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.
>
> --Rob
>

wc -l returns 3 lines. But when I process the file in php (save each line
in to an array and then produce a count), it reports 4 lines as does
gedit.





More information about the fedora-list mailing list