grep line length limit


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grep line length limit
# 1  
Old 10-01-2006
grep line length limit

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.
# 2  
Old 10-02-2006
As a guess - the line length is 2045. When grep attempts to write the line number
plus the original line, then the 2048 limit for I/O is exceeded.

Edit -
I cannot duplicate this problem, the line size limit is not the same.

Last edited by jim mcnamara; 10-02-2006 at 12:25 PM..
# 3  
Old 10-02-2006
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:
Code:
for linenum, lines in enumerate(open("file.txt")):
     if "expr" in lines:
          print "Line number: " , linenum

# 4  
Old 10-02-2006
Thanks Jim. That might be the cause.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Limit string length with sed

Hi. I'm trying to learn sed. I want to limit the length of a string. I tried this: sed -n 's/^\(...........................\).*/\1/p' textfile.txt This works fine, but how do I give it as a range rather than putting a hundred dots? I'd like to limit the number of characters to 144 for... (3 Replies)
Discussion started by: troglodytes
3 Replies

2. Shell Programming and Scripting

Check for length which exceeds specified length in a line

Hi, I have a issue, I need to loop through a comma delimited file and check for the length which exceeds specified length , if Yes truncate the string. But my problem is , I do not have to check for all the fields and the field lenght is not same for all the fields. For ex: Say my line... (9 Replies)
Discussion started by: rashmisb
9 Replies

3. Shell Programming and Scripting

Find files and seach limit with grep

Hi, I'm testing nginx-cache-purge and notice that grep searches all file content, and since the cache key is in the second line I would like to limit grep searching. This is the script I'm using: github.com/perusio/nginx-cache-purge The line I would like to change and limit grep search... (5 Replies)
Discussion started by: nfn
5 Replies

4. Shell Programming and Scripting

grep by limit search

Hi I am in new in unix,can any one tell how to grep the data by limit. suppose I have below data:- is :mSecs is :mSecs is :mSecs is :mSecs requirement is how to grep the data which is having count greater than 1000 msecs only. thanks in adnavce. (2 Replies)
Discussion started by: abhigrkist
2 Replies

5. Programming

Is there a limit for a code line length in C?

Is there any stabdard limitation on size of a code line in C code? I am interesting in UNIX limitation, particulary on SUN. Thanks! (8 Replies)
Discussion started by: alex_5161
8 Replies

6. Shell Programming and Scripting

AWK limit for (length) function?

I am trying to use the following code: awk '{s=$0;if(length(s) < 750){getline; s=s " " $0}printf("%s\n",s)}' filename but an error shows that 'awk' is too long. Is there a limit to the awk length function? and what could be an alternate solution for long fixed width records? The code... (3 Replies)
Discussion started by: CKT_newbie88
3 Replies

7. Cybersecurity

~ IPTables : Limit Incoming UDP Packets With a Certain Length ~

Hello, I am currently trying to limit incoming UDP length 20 packets on a per IP basis to 5 a second using IPTables on a Linux machine (CentOS 5.2). Basically, if an IP is sending more than 5 length 20 UDP packet a second to the local machine, I would like the machine to drop the excess... (1 Reply)
Discussion started by: tomboy123
1 Replies

8. Shell Programming and Scripting

Deleting Characters at specific position in a line if the line is certain length

I've got a file that would have lines similar to: 12345678 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 23456781 x.00 xx.00 xx.00 xx.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 34567812 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 45678123 x.00 xx.00 xx.00 xx.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 xx.00... (10 Replies)
Discussion started by: Cailet
10 Replies

9. UNIX for Dummies Questions & Answers

limit of command length

Hi! Can you please help me with one question? Does rexec command have some limitation of the length of the deliveded cmd? Thanks in advance, Anta (2 Replies)
Discussion started by: Anta
2 Replies

10. AIX

Is the Length of User ID for AIX Limit to 8 Characters?

Hi, I'm using AIX version 5.3 currently. I'm trying to create a user id, e.g. andyleong, which the system prompted the length is too long. 1. I would like to know is that the length of user id is limited to maximum 8 characters for AIX. 2. Is it apply to all versions of AIX? If no... (2 Replies)
Discussion started by: meihua_t
2 Replies
Login or Register to Ask a Question