The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 10-02-2006
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,554
Quote:
Originally Posted by hnhegde
Hi Friends,

I am having a funny problem with grep. When I run
grep 'expr' file.txt
things work fine. But when try to get the line number using the -n option, i.e,
grep -n 'expr' file.txt
I get a message, "grep: 0652-226 Maximum line length of 2048 exceeded."

If the line has more than 2048 characters, then I should have got the error in the first case also. Can somebody please explain why the error is only with the -n option? I am running on AIX 5.1.0.0

Thanks.
That's where you do not have control...over the tools you use.
If you have Python in your AIX already:
for linenum, lines in enumerate(open("file.txt")): if "expr" in lines: print "Line number: " , linenum
Code:
for linenum, lines in enumerate(open("file.txt")):
     if "expr" in lines:
          print "Line number: " , linenum
        
-->
Code:
for linenum, lines in enumerate(open("file.txt")):
     if "expr" in lines:
          print "Line number: " , linenum