It is currently Thu, 20 Jan 2022 04:12:31 GMT



 
Author Message
 long line length causes grep crash
In a kshell script I execute a grep command on a file which lines can be
greater than 2048 characters.
The following error : "grep : maximum line length of  2048 exceeded"
occurs.
Is there a simple way to increase this maximum line length?
Thank you for your answers.


 Sun, 16 Jan 2005 01:29:23 GMT   
 long line length causes grep crash
On Tue, 30 Jul 2002 19:29:23 +0200,
 Eric Petitpierre <epeti...@free.fr> wrote:
Install GNU grep, part of the GNU textutils package, or maybe you can use
perl.


 Sun, 16 Jan 2005 01:52:27 GMT   
 long line length causes grep crash
Thank you for this answer. However is there no way to resolve this problem
by changing the value of this maximum line length? Or is it hard-coded in
Unix?

"Bill Marcum" <bmar...@iglou.com> a crit dans le message news:
slrnakdkgs.6bg.bmar...@gigs.localnet...



 Sun, 16 Jan 2005 01:54:25 GMT   
 long line length causes grep crash
Eric Petitpierre said:

i'm not sure if i can repeat your problem, for me everything works fine:

+- perl -e 'print "A" x33554432' |grep aa

...until the input line is not longer than 33554432 chars:

+- perl -e 'print "A" x33554433' |grep aa
grep: memory exhausted

+- grep -V
grep (GNU grep) 2.4.2
+- echo $BASH_VERSION
2.05.0(1)-release

in grep sources it looks like the most important variable is
MAX_BUF_SIZE defined in file $grep_src/lib/regex.c

--
Jacek Pospychala       e-mail: tri...@bsod.org
http://tri10o.republika.pl http://www.bsod.org



 Sun, 16 Jan 2005 02:08:25 GMT   
 long line length causes grep crash
in comp.unix.shell i read:

recompile.

--
bringing you boring signatures for 17 years



 Sun, 16 Jan 2005 02:07:09 GMT   
 long line length causes grep crash

You can't "fix" the standard Unix command.  The best you can do is
to filter the file through fold(1) first:

fold -w<number of columns> file | grep pattern

Of course, then the long lines are broken up into two or more
individual lines.



 Sun, 16 Jan 2005 02:19:40 GMT   
 long line length causes grep crash
I have this same problem at work on an AIX box. I solved it by using awk,
which doesn't seem to be affected by this implemenation.

awk '/^.{95}ISA/' somefile.dat

For instance, the above command would match the text string 'ISA' in column
96 and only return records that matched the regex. Of course I'd probably
pipe this output into a file, another command or maybe a shell variable for
further introspection and handling ...

http://azplace.net
http://strausplace.com

news:slrnakdkgs.6bg.bmarcum@gigs.localnet...



 Sun, 16 Jan 2005 16:19:51 GMT   
 
   [ 7 post ] 

Similar Threads

1. Grep 2K Line Length?

2. find length longest line in a file

3. a SED script to find length of the longest line in a file

4. one liner which prints n lines before and m lines after the line found by grep

5. Csh crashes on very long lines

6. grep and grep -o line count differ

7. Anwser: Possible causes to crashes caused by network (3c509)

8. Command line: How long is too long?

9. Length problem in grep command

10. on using grep to get words of a certain length


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software