From: kaushal on 8 Jun 2010 10:45 Hi, can someone explain me about the usage of grep , fgrep and egrep with examples. In what contexts i should use this. Please guide/suggest Thanks and Regards, Kaushal
From: Teemu Likonen on 8 Jun 2010 10:50 * 2010-06-08 07:45 (-0700), kaushal wrote: > can someone explain me about the usage of grep , fgrep and egrep with > examples. In what contexts i should use this. Start with this command: $ man grep Or read the manual of GNU grep from here: http://www.gnu.org/software/grep/manual/html_node/index.html (There are examples too.)
From: Ed Morton on 8 Jun 2010 12:06 On Jun 8, 9:45 am, kaushal <kaushalshri...(a)gmail.com> wrote: > Hi, > > can someone explain me about the usage of grep , fgrep and egrep with > examples. > In what contexts i should use this. > > Please guide/suggest > > Thanks and Regards, > > Kaushal Use grep to find text in a file, e.g. $ cat file here is some text $ grep "so" file some I wouldn't bother with fgrep or egrep. If you have to do anything more complicated than that you may as well learn sed or awk as, with the exception of a couple of cute GNU grep extensions, their syntax is as simple as greps for what grep does but they're extensible to do things grep can't do. The most extensible with the simplest syntax for anything even moderately complex is awk but sed is also very useful for simple searching/subsitutions on a single line. Ed.
From: Kenny McCormack on 8 Jun 2010 12:40 In article <d8cbd965-3be1-4c65-b97f-b1a17072227a(a)y11g2000yqm.googlegroups.com>, Ed Morton <mortonspam(a)gmail.com> wrote: .... >I wouldn't bother with fgrep or egrep. If you have to do anything more >complicated than that you may as well learn sed or awk as, with the >exception of a couple of cute GNU grep extensions, their syntax is as >simple as greps for what grep does but they're extensible to do things >grep can't do. The most extensible with the simplest syntax for >anything even moderately complex is awk but sed is also very useful >for simple searching/subsitutions on a single line. I agree with your general sentiment, and also your recommendation of AWK (as the best balance between high level and low level). I disagree with the (tepid) recommendation of sed - I find that once one knows AWK, sed drops off the radar. But, having said that, the fact is, this is comp.unix.shell, and one of the groupthink principles of this newsgroup is that you *should* learn the plethora of tools (join, comm, pr, sed, etc) and use them all. Also, all the shell built-ins, like "read", etc. Finally, my guess at the underlying meaning of the OP is that he is dealing with existing code and/or a corporate situation where knowing all these obscure tools is going to be necessary for him to work. I know that in one of my former jobs, a lot of the existing shell codebase used all these tools (join, comm, pr, sed, etc) to do things that could have been done much more easily with a single, unified AWK script. But ya gotta deal... -- > No, I haven't, that's why I'm asking questions. If you won't help me, > why don't you just go find your lost manhood elsewhere. CLC in a nutshell.
From: Janis Papanagnou on 8 Jun 2010 13:24 kaushal wrote: > Hi, > > can someone explain me about the usage of grep , fgrep and egrep with > examples. > In what contexts i should use this. grep - if you're using simple regexps fgrep - if you use literal strings egrep - if you use extended regexps Some samples to illustrate... echo 'xyz' | grep x.z echo 'xyz' | fgrep x.z echo 'hello' | grep 'hello|world' echo 'hello' | egrep 'hello|world' And of course, as already proposed, man grep is your friend. Janis > > Please guide/suggest > > Thanks and Regards, > > Kaushal
|
Next
|
Last
Pages: 1 2 Prev: wget -r (recursive) failing to back up a site Next: how to optionally silence lines in script |