LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-10-2005, 04:11 PM   #1
tuananhbirm
Member
 
Registered: Apr 2004
Posts: 40

Rep: Reputation: 15
Understand |


Hi, could any one tell me (pretty in detail) what the symbol "|" does besides indicates OR in creating a pattern ?
For example, what would happen if i type:
grep a * | grep b | grep c .....

?

Thanks a lot
 
Old 01-10-2005, 04:24 PM   #2
tuananhbirm
Member
 
Registered: Apr 2004
Posts: 40

Original Poster
Rep: Reputation: 15
And by the way, can anyone tell me the best way to write a regular expression to find all words contains a, b and c (in any order) ?
 
Old 01-10-2005, 04:55 PM   #3
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86; Gentoo PPC; Gentoo Sparc64; FreeBSD; OS X; Solaris
Posts: 3,731
Blog Entries: 4

Rep: Reputation: 68
'|' does not mean 'or', '||' means 'or'.

'|' is a pipe, which redirects the output from the command on the left, to input of the command on the right...

Quote:
For example, what would happen if i type:
grep a * | grep b | grep c
This will search every file in the current directory for lines with an 'a' in them, from these results it will search lines for 'b', and then for 'c'...so basically it will print every line from any file that has an 'a' _and_ a 'b' _and_ a 'c' in them.
 
Old 01-10-2005, 05:02 PM   #4
tuananhbirm
Member
 
Registered: Apr 2004
Posts: 40

Original Poster
Rep: Reputation: 15
Thanks for your reply !
Is there a better way to search for such pattern using regular expression ?

I came up with thing like:
grep -E (.*a.*b.*c.*|.*a.*c.*b.*|.*b.*a.*c.*|.*b.*c.*.a* ......) *

but it looked clumsy though.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me understand what this is saying. Distorted.Clarity Linux - Newbie 11 12-13-2005 07:31 PM
Need help to understand C4bo Debian 2 06-13-2005 06:53 AM
Help me Understand what I have to do... cjkeeme Linux - Networking 5 05-15-2005 02:05 PM
understand 1.4 mAineAc Linux - Software 6 01-06-2005 01:59 AM
i don't understand... humanveal Linux - Software 17 05-20-2003 03:24 AM


All times are GMT -5. The time now is 04:46 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration