LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   grep file (https://www.linuxquestions.org/questions/linux-newbie-8/grep-file-731870/)

ust 06-10-2009 03:45 AM

grep file
 
I would like to ask if I want to grep somthing .

I know the command " ll |grep Jun" can grep file with Jun , if I want to grep file with May and Jun , what can i do ? thx

Nylex 06-10-2009 03:46 AM

Yes you can use grep to search through files. Read the man page..

Simple example: grep "foo" stuff - this searches for the string "foo" in the file "stuff".

jdkaye 06-10-2009 03:50 AM

Just use the "man" command to find out things like this.
Code:

man grep
gives this information:
Quote:

Alternation
Two regular expressions may be joined by the infix operator |; the
resulting regular expression matches any string matching either alternate
expression.
cheers,
jdk

pixellany 06-10-2009 04:43 AM

Quote:

Originally Posted by ust (Post 3568923)
I would like to ask if I want to grep somthing .

I know the command " ll |grep Jun" can grep file with Jun , if I want to grep file with May and Jun , what can i do ? thx

Do you mean "May and Jun", or possibly "May OR Jun".

OR:
egrep '(May|Jun)' filename

AND:
egrep 'May' filename | egrep 'Jun'

Note the two very different meanings of the "|" operator.


All times are GMT -5. The time now is 11:16 PM.