LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Shell-script: search item in any order (https://www.linuxquestions.org/questions/programming-9/shell-script-search-item-in-any-order-27246/)

macone 08-05-2002 10:31 AM

Shell-script: search item in any order
 
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??

dbl221 08-08-2002 08:03 PM

try awk instead.

macone 08-09-2002 12:52 AM

I've got an easy solution interim:

grep PATTERN1 file | grep PATTERN2

Anyway thank you for answering.

biosx 08-13-2002 10:44 AM

Look at Regular Expressions. Perl supports them internally and it will help you find and/or parse data easily. There should be many tutorials and/or references available online.

good luck


All times are GMT -5. The time now is 06:59 AM.