I just realized that there's actually a very simple way to check if a long line might be causing the problem; you can use "wc -L" to check the length of the longest line in a text document.
Code:wc -L /path/to/somefile.txt
I just realized that there's actually a very simple way to check if a long line might be causing the problem; you can use "wc -L" to check the length of the longest line in a text document.
Code:wc -L /path/to/somefile.txt
It doesn't return a line number, it returns the length of the longest line.
If you prefer, you can also use awk to print the length together with the text of the longest line:
Code:awk ' { if ( length > L ) { L=length ;s=$0 } }END{ print L,"\""s"\"" }' /path/to/somefile.txt
Last edited by mcduck; November 15th, 2010 at 11:20 PM.
ok.
That number was 973.
Do you think a line that is 973 chars long is choking gedit?
I just tested creating a text file with a 1000-character line, and it did open in Gedit, although with even a single line that long it did take a good while to load.
But anyway, that would mean that the line legth, at least alone, can't be the problem.
Sorry, but I really have no further ideas, as the long line(s) are actually the only information we have about the file in question. Hopefully somebody else comes up with some other idea.
I have seen a similar problem in a completely unrelated system/software, where the extra length in the line was due to spaces. Does the command you tried count spaces?
McDuck, did your 1000 character line have spaces?
The OP's example lines had a space about every third character.
EDIT; Just checked it myself, and the command does count space.....oh well worth a shot.
Last edited by migs73; November 16th, 2010 at 10:09 AM.
Dell Inspiron 1501 AMD Sempron, 4GB RAM, 120GB HDD, running 14.04 64Bit
Dell Latitude D830 Centrino duo 4GB RAM 320GB HDD, running 13.10 64Bit
Raspberry Pi running Rasbian
Ubuntu User #32384
no, I just used a simple script to generate the file so it had no spaces.
Of course I could test with spaces, or multiple long lines.
Anyway, even the single 1000-char line took a good 8 seconds to load in Gedit, so it definitely does have some issues with such long lines. Maybe if there are couple of such long lines, or if the file is otherwise large enough, that would result in the file not opening at all. But that's just guessing.
Mcduck
Maybe you missed my edit, but the command does count spaces so it isn't that. You might be on to something with the multiple long lines.
FYI the case I was referring to was a text editor/compiler that would accept commands at any length, but when you download into a BASIC module in a PLC it would fall over as the lines were to long, even though the lines we added were not the longest. It seemed the compiler ignored spaces but the module 'counted' them (even though the file was downloaded from the module in the first place).
Very confusing.
Dell Inspiron 1501 AMD Sempron, 4GB RAM, 120GB HDD, running 14.04 64Bit
Dell Latitude D830 Centrino duo 4GB RAM 320GB HDD, running 13.10 64Bit
Raspberry Pi running Rasbian
Ubuntu User #32384
It has nothing to do with spaces or line length....imo
Remember, the file is an apache log file. I have literally hundreds of them and have never had this problem. It is also the ONLY one gedit cannot open. The only way I could see either of those being a problem is if someone maybe tried hacking and the entry went into the logs and had all kinds of garbage code in the line. But the file is about 200MB now (it's growing as we speak) and finding a bad line is like looking for a needle in a haystack. I may just rotate the log and let apache create a fresh one. I do believe the cure is that simple, however, I would like to find a solution as this could possibly happen again and I like to use gedit to open the file occasionally and scan the entries for unusual activity.
The log still works, apache is still appending new entries to it and AWSTATS is apparently reading the info from it just fine as it updates every morning and I can see it's updating and looks accurate.
The error says that it is not "Encoded" properly, yet I cannot find any problem with the file.
I can open it with GVIM also with no problem...but I personally find gvim a bit tedious.
So at this point, my best guess is that it's a bug with gedit.
Last edited by mistypotato; November 18th, 2010 at 02:26 PM.
Bookmarks