Click to See Complete Forum and Search --> : Shell-script: search item in any order


macone
08-05-2002, 11:29 AM
Hello altogether,

I have got the following problem:

- every line in a textfile corresponds to a data record
- now i want to search for a certain data record with grep e.g.

so far so good.

But what, if I want to use several search items (and I don't no their order in the data record) at the same time to serach for a dedicated data record??

Quasi "grep PATTERN1&PATTERN2 /home/file" whereupon it doesn't matter in which order "PATTERN1" and "PATTERN2" occurs in "/home/file".

Has anybody an idea??

cwolf
08-07-2002, 06:00 AM
Maybe egrep can do what you want:
egrep '(PATTERN1|PATTERN2)' /home/file

macone
08-07-2002, 07:35 AM
Hello cwolf,

thank you for answering!

Originally posted by cwolf
Maybe egrep can do what you want:
egrep '(PATTERN1|PATTERN2)' /home/file

But the way that you have posted corresponds a disjunction. What I need is an AND gating. Interim I know the right way:

grep PATTERN1 file | grep PATTERN2