agrep: pattern too long


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting agrep: pattern too long
# 1  
Old 03-11-2008
agrep: pattern too long

agrep -d Seconds "29 06 0e 2b 06 01 04 01 9d 64 03 08 02 01 05 05" filename
agrep: pattern too long

Guys,

I am trying to grep for some data in a flat ascii file and I get this error, can someone please help me out
# 2  
Old 03-11-2008
Quote:
Originally Posted by knijjar
agrep -d Seconds "29 06 0e 2b 06 01 04 01 9d 64 03 08 02 01 05 05" filename
agrep: pattern too long

Guys,

I am trying to grep for some data in a flat ascii file and I get this error, can someone please help me out
I just tried this and I get a slightly more explicit message:

agrep: pattern too long (has > 32 chars)

Interestingly, if I trim it down to 26 characters it still makes this claim. I think it's including your "Seconds" as part of the pattern. Maybe try taking advantage of the -f flag and putting your patterns into a text file.

ShawnMilo
# 3  
Old 03-12-2008
Hi.

The man agrep on my system reads:
Quote:
There is no size limit for simple patterns. More complicated patterns
are currently limited to approximately 30 characters.

Regular expressions are currently limited to approx-
imately 30 characters (generally excluding meta characters).
Some options (-d, -w, -f, -t, -x, -D, -I, -S) do not currently
work with regular expressions.
excerpt from man agrep
However, the man page is not clear (to me) on how one distinguishes a pattern from a simple string.

Best wishes ... cheers, drl
# 4  
Old 03-12-2008
Hi.

My experiments:
Code:
#!/usr/bin/env sh

# @(#) s1       Demonstrate [ac]grep, copying a group of lines.

#  ____
# /
# |   Infrastructure BEGIN

echo
set -o nounset

debug=":"
debug="echo"

## The shebang using "env" line is designed for portability. For
#  higher security, use:
#
#  #!/bin/sh -

## Use local command version for the commands in this demonstration.

set +o nounset
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version =o $(_eat $0 $1) grep agrep cgrep
set -o nounset

echo

FILE=${1-data1}
echo " Input file $FILE:"
cat $FILE

# |   Infrastructure END
# \
#  ---

echo
echo ' Results from grep:'
grep '29 06 0e 2b 06 01 04 01 9d 64 03 08 02 01 05 05' $FILE

echo
echo ' Results from agrep:'
agrep '29 06 0e 2b 06 01 04 01 9d 64 03 08 02 01 05 05' $FILE

echo
echo ' Results from agrep with -d:'
agrep -d seconds '29 06 0e 2b 06 01 04 01 9d 64 03 08 02 01 05 05' $FILE

echo
echo ' Results from agrep with -d -k:'
agrep -d seconds -k '29 06 0e 2b 06 01 04 01 9d 64 03 08 02 01 05 05' $FILE

echo
echo ' Results from agrep with -d <>:'
agrep -d seconds '<29 06 0e 2b 06 01 04 01 9d 64 03 08 02 01 05 05>' $FILE

echo
echo ' Results from cgrep:'
cgrep +I2 -+w seconds '29 06 0e 2b 06 01 04 01 9d 64 03 08 02 01 05 05' $FILE

exit 0

Producing:
Code:
% ./s1

(Versions displayed with local utility "version")
Linux 2.6.11-x1
GNU bash, version 2.05b.0(1)-release (i386-pc-linux-gnu)
grep (GNU grep) 2.5.1
agrep (local) - no version provided.
cgrep (local) - no version provided.

 Input file data1:
seconds
nothing here

seconds
junk
29 06 0e 2b 06 01 04 01 9d 64 03 08 02 01 05 05
junk

seconds
junk
still no match
more junk

 Results from grep:
29 06 0e 2b 06 01 04 01 9d 64 03 08 02 01 05 05

 Results from agrep:
29 06 0e 2b 06 01 04 01 9d 64 03 08 02 01 05 05

 Results from agrep with -d:
agrep: pattern too long

 Results from agrep with -d -k:
agrep: pattern too long

 Results from agrep with -d <>:
agrep: pattern too long

 Results from cgrep:
========================================
seconds
junk
29 06 0e 2b 06 01 04 01 9d 64 03 08 02 01 05 05
junk

The source for the successful cgrep may be obtained from: cgrep home page

You'll need to compile and install it, but it went easily for me. If that's not an acceptable option for you, then perhaps one of the awk experts will stop by and help ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

2. Shell Programming and Scripting

sed and awk usage to grep a pattern 1 and with reference to this grep a pattern 2 and pattern 3

Hi , I have a file where i have modifed certain things compared to original file . The difference of the original file and modified file is as follows. # diff mir_lex.c.modified mir_lex.c.orig 3209c3209 < if(yy_current_buffer -> yy_is_our_buffer == 0) { --- >... (5 Replies)
Discussion started by: breezevinay
5 Replies

3. UNIX for Dummies Questions & Answers

Match Pattern after certain pattern and Print words next to Pattern

Hi experts , im new to Unix,AWK ,and im just not able to get this right. I need to match for some patterns if it matches I need to print the next few words to it.. I have only three such conditions to match… But I need to print only those words that comes after satisfying the first condition..... (2 Replies)
Discussion started by: 100bees
2 Replies

4. Shell Programming and Scripting

Insert new pattern in newline after the nth occurrence of a line pattern - Bash in Ubuntu 12.04

Hi, I am getting crazy after days on looking at it: Bash in Ubuntu 12.04.1 I want to do this: pattern="system /path1/file1 file1" new_pattern=" data /path2/file2 file2" file to edit: data.db - I need to search in the file data.db for the nth occurrence of pattern - pattern must... (14 Replies)
Discussion started by: Phil3759
14 Replies

5. Shell Programming and Scripting

Need one liner to search pattern and print everything expect 6 lines from where pattern match made

i need to search for a pattern from a big file and print everything expect the next 6 lines from where the pattern match was made. (8 Replies)
Discussion started by: chidori
8 Replies

6. Shell Programming and Scripting

Replacing or removing a long list of pattern by using awk or sed

Input: >abc|123456|def|EXIT| >abc|203456|def|EXIT2| >abc|234056|def|EXIT3| >abc|340056|def|EXIT4| >abc|456000|def|EXIT5| . . . Output: def|EXIT| def|EXIT2| def|EXIT3| def|EXIT4| def|EXIT5| . . My try code: (9 Replies)
Discussion started by: patrick87
9 Replies

7. Shell Programming and Scripting

Why does '$$' means an empty line in agrep -d '$$'

Hi all, Why does '$$' means an empty line in agrep -d '$$'. I did not know that '$$' can be seen as an empty line in regular expression. So did I miss something here ? Thanks! (4 Replies)
Discussion started by: qiulang
4 Replies

8. Shell Programming and Scripting

How to specify two delimiters in agrep for record definition ?

Hi all, How to specify two delimiters in agrep for record definition, one for the beginning of the record and the other for the end ? Most of examples I see so far only specify 1 delimiter, e.g. agrep -d '^From ' 'pizza' mbox. But that won't work for me. I need to 2 delimiters to indicate the... (2 Replies)
Discussion started by: qiulang
2 Replies

9. Shell Programming and Scripting

search a pattern and if pattern found insert new pattern at the begining

I am trying to do some thing like this .. In a file , if pattern found insert new pattern at the begining of the line containing the pattern. example: in a file I have this. gtrow0unit1/gctunit_crrownorth_stage5_outnet_feedthru_pin if i find feedthru_pin want to insert !! at the... (7 Replies)
Discussion started by: pitagi
7 Replies

10. UNIX for Dummies Questions & Answers

Vi - "The replacement pattern is too long"

Hi, I am trying to replace a value in a script with another value. I am performing a vi command from another script. vi - ${conf_path}/CANCEL_CD_PART2.txt<<! :%s/RANGE/${btch_range}/g :wq ! 'RANGE' is the current value that the parm in the other script has (PARM1=RANGE), along with... (3 Replies)
Discussion started by: hern14
3 Replies
Login or Register to Ask a Question