Subject: Re: One of those grep questiony things.
Subject: Re: referencing certain fields with egrep
Subject: Re: ? about grep
Subject: Re: How to grep a dir tree?
From: gjohnson@dream.season.com (Reality is a point of view)
Newsgroups: alt.unix.wizards
Subject: Re: One of those grep questiony things.
Date: 28 Feb 1996 07:07:30 GMT
Lines: 27
+---- txk@cs.bham.ac.uk wrote:
| I am using grep in the following way as part of a script file...
| cat $TEMP | grep .ac.uk
| The problem is that the '.'s are ignored
+----
Try grep '\.ac\.uk' instead.
grep is regular expression aware and . is a regular expression
special character that means "match any single character except
newline". So
cat foo
aaa
aba
abb
a.a
grep 'a.a' foo
aaa
aba
a.a
grep 'a\.a' foo
a.a
--
Gary Johnson "I'd a done sumpin too, but I ain't no Peckerton Ditinctive."
gjohnson@season.com
--
Newsgroups: comp.unix.questions
From: bmarcum@iglou.iglou.com (Bill Marcum)
Subject: Re: referencing certain fields with egrep
Date: Mon, 4 Mar 1996 02:00:38 GMT
Lines: 20
In article <4hcqbt$aod@gondor.sdsu.edu>,
Jason Larson <larsonj@rohan.sdsu.edu> wrote:
>I need to know how to refrence a certain field using egrep.
>I have a file with a certain number of words sparated by commas and
>spaces. ex:
>asfas, fas sdh, iemnc, feb28, ddhus, fddd
>
>How can I refer to say the second or third field *only*
>I can do this with sort easily but I need grep to weed out what
>I am not looking for.
>I have tried specifying the pattern with ', pattern' but then it
>is also refering to other other fields.
>Any help is greatly appreciated.
>
You asked how to do it with egrep, but with awk you can simply write
awk -F, '$2~/pattern/ {print}'
--
Bill Marcum bmarcum@iglou.com
"They're all lawyers, and think that the laws of physics can be amended with
a voice vote." -- Mary Shafer (shafer@ursa-major.spdcc.com) on Politicians
--
Newsgroups: comp.unix.questions
From: bmarcum@iglou2.iglou.com (Bill Marcum)
Subject: Re: ? about grep
Date: Mon, 4 Mar 1996 19:18:07 GMT
Lines: 14
In article <4hfbkd$3t7g@holly.ACNS.ColoState.EDU>,
Stuart Mcfarland <muggs@holly.ACNS.ColoState.EDU> wrote:
>can I specify the number of times a string should appear and have grep
return false
>if the string appears more often, or make grep indicate how often a
string occurs? >...or anything along those lines...thx
You could do it with awk
awk '/pattern/{counter++;if(counter>=5) exit 1}' filename
--
Bill Marcum bmarcum@iglou.com
"They're all lawyers, and think that the laws of physics can be amended with
a voice vote." -- Mary Shafer (shafer@ursa-major.spdcc.com) on Politicians
--
From: Tom Kralidis <tom.kralidis@ccrsDotnrcandOtgc.ca>
Newsgroups: comp.unix.questions,comp.unix.misc
Subject: Re: How to grep a dir tree?
Date: Mon, 22 Mar 1999 10:33:21 -0500
Lines: 21
Mime-Version: 1.0
That didn't work. The following did:
% find . type f -print | xargs grep -il string
..Tom
Jim Trocki wrote:
>
> In article <36F651BD.F082099C@ccrsDotnrcandOtgc.ca>,
> Tom Kralidis <tom.kralidis@ccrsDotnrcandOtgc.ca> wrote:
>
> >I need to edit all files with a specific string, but I need to find them
> >first. Can I do a grep on an entire tree? I tried man grep but no
> >luck. There is an expression optiuon that I tried that failed, bad
> >conjuction
> >
> >find . -type f -name "*.*" \"gcpdbb\" -print
> >
> >Any ideas or alternatives??
>
> grep "specific string" `find . -type f -print`
--
|
Hosted by: |
|
©copyright 1995-2002 sysinfo.com