|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Guys,
I want to browse thru a file for a particular keyword.. ex: I want to go to all the places i.e where the keyword "temp" is used in a file <abc.log> Thanks |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Tue, 17 Jul 2007 11:32:23 -0700, saam
<shaiksameer@gmail.com> wrote: > > > Guys, > > I want to browse thru a file for a particular keyword.. > > ex: I want to go to all the places i.e where the keyword "temp" is > used in a file <abc.log> > > Thanks > grep temp abc.log -- People in general do not willingly read if they have anything else to amuse them. -- S. Johnson |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
In article <j9hvm4-u0f.ln1@don.localnet>,
Bill Marcum <marcumbill@bellsouth.net> wrote: > On Tue, 17 Jul 2007 11:32:23 -0700, saam > <shaiksameer@gmail.com> wrote: > > > > > > Guys, > > > > I want to browse thru a file for a particular keyword.. > > > > ex: I want to go to all the places i.e where the keyword "temp" is > > used in a file <abc.log> > > > > Thanks > > > grep temp abc.log When he says "browse", I suspect he means interactively view the sections of the file containing the keyword. I suggest: less abc.log /temp Then type "n" to get to each successive occurrence. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group *** |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Jul 17, 2:32 pm, saam <shaiksam...@gmail.com> wrote:
> Guys, > > I want to browse thru a file for a particular keyword.. > > ex: I want to go to all the places i.e where the keyword "temp" is > used in a file <abc.log> > > Thanks The easiest way would be to use grep $grep temp abc.log but if you want to substitute something for the word "temp" then sed will come in handy. Lets say you want to substitute every occurrence of the word "temp" with the word "newword" then following command will . $ sed 's/temp/newword/g' abc.log > newabc.log Remember, sed by default does not changes the actual file until you tell it to do so; hence newabc.log file is created here. Hope it s. R |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Jul 17, 2:32 pm, saam <shaiksam...@gmail.com> wrote:
> Guys, > > I want to browse thru a file for a particular keyword.. > > ex: I want to go to all the places i.e where the keyword "temp" is > used in a file <abc.log> > > Thanks The easiest way would be to use grep $grep temp abc.log but if you want to substitute something for the word "temp" then sed will come in handy. Lets say you want to substitute every occurrence of the word "temp" with the word "newword" then following command will . $ sed 's/temp/newword/g' abc.log > newabc.log Remember, sed by default does not changes the actual file until you tell it to do so; hence newabc.log file is created here. Hope it s. R |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On Jul 17, 11:32 am, saam <shaiksam...@gmail.com> wrote:
> Guys, > > I want to browse thru a file for a particular keyword.. > > ex: I want to go to all the places i.e where the keyword "temp" is > used in a file <abc.log> > > Thanks Grep !! General use of grep, grep pattern filename, Like... grep "temp" thefile.txt To see the line number, if you want that, grep -n "temp" thefile. Alt uses, -i for any case. pipe then grep cat mylog.log |grep "fun" # save the result, handy, cat mylog.log | grep "fun" >vas.ist.da.txt # will find Fun, FUN fUn fUN cat mylog.log | grep -i "fun" Some Egrep, .. for any char [] things in this set * da, many. ^ start of line $ end of the line + one or more of the thing to the left Eg: grep . mylog.log |egrep "^fun" # match on afun bfun 1fun grep . mylog.log |egrep ".fun" # run fun grep . mylog.log |egrep "[rf]un" # 1fun 2fun 3fun , thus is a set, any of the items in the set. grep . mylog.log | egrep "[123]fun" # range of things in a set, 1fun 2fun 3fun 4fun 5fun grep . mylog.log | egrep "[1-5]fun" # handy, seek 0 to 9, 0fun 1fun or 00fun grep . mylog | egrep "[0-9]+fun" # my fav, seek 100, 111, 125, 199, grep . mylog.log | egrep "[1-9][0-9][0-9]" Just 2 cents, JB |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Jul 17, 11:32 am, saam <shaiksam...@gmail.com> wrote:
> Guys, > > I want to browse thru a file for a particular keyword.. > > ex: I want to go to all the places i.e where the keyword "temp" is > used in a file <abc.log> > > Thanks Grep !! General use of grep, grep pattern filename, Like... grep "temp" thefile.txt To see the line number, if you want that, grep -n "temp" thefile. Alt uses, -i for any case. pipe then grep cat mylog.log |grep "fun" # save the result, handy, cat mylog.log | grep "fun" >vas.ist.da.txt # will find Fun, FUN fUn fUN cat mylog.log | grep -i "fun" Some Egrep, .. for any char [] things in this set * da, many. ^ start of line $ end of the line + one or more of the thing to the left Eg: grep . mylog.log |egrep "^fun" # match on afun bfun 1fun grep . mylog.log |egrep ".fun" # run fun grep . mylog.log |egrep "[rf]un" # 1fun 2fun 3fun , thus is a set, any of the items in the set. grep . mylog.log | egrep "[123]fun" # range of things in a set, 1fun 2fun 3fun 4fun 5fun grep . mylog.log | egrep "[1-5]fun" # handy, seek 0 to 9, 0fun 1fun or 00fun grep . mylog | egrep "[0-9]+fun" # my fav, seek 100, 111, 125, 199, grep . mylog.log | egrep "[1-9][0-9][0-9]" Just 2 cents, JB |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
On Jul 17, 1:04 pm, Bill Marcum <marcumb...@bellsouth.net> wrote:
> On Tue, 17 Jul 2007 11:32:23 -0700, saam <shaiksam...@gmail.com> wrote: > > > Guys, > > > I want to browse thru a file for a particular keyword.. > > > ex: I want to go to all the places i.e where the keyword "temp" is > > used in a file <abc.log> > > > Thanks > > grep temp abc.log > > -- > People in general do not willingly read if they have anything else to > amuse them. > -- S. Johnson I did a reply to this early today, hmmm, issues,,,,,,,,,, JB |
|
![]() |
| Outils de la discussion | |
|
|