3 patterns in one line


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users 3 patterns in one line
# 1  
Old 02-16-2008
3 patterns in one line

hello, I want to write a script to find all the files that contain 3 specific patterns. example: shows the files containing any line that contain pattern1, pattern2 and pattern3, but the patterns can be in any order as long as they exist in the line.
can I do that with grep?
thank you
# 2  
Old 02-16-2008
Under any Unix or Linux, to find...:
- by searching from /your_start_dir directory
- all files with .txt extension
- also by following symbolic links, if any
- for each such file, execute a regular expression search with :
- _Extended grep
- _list only file names (without -l, will also print found lines)
- do the search case _insensitive
- search pattern pat1 or pat2 or pat3
type this command:
find /your_start_dir -name '*.txt' -follow -exec grep -E -l -i 'pat1|pat2|pat3' {} \;
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find matched patterns and print them with other patterns not the whole line

Hi, I am trying to extract some patterns from a line. The input file is space delimited and i could not use column to get value after "IN" or "OUT" patterns as there could be multiple white spaces before the next digits that i need to print in the output file . I need to print 3 patterns in a... (3 Replies)
Discussion started by: redse171
3 Replies

2. Shell Programming and Scripting

Matched multiple patterns that could be in a same line

Hi, I need help to match pattern started with "RW" in file 1 and with pattern in $1 in file 2 as follows:- File 1 BH /TOTAL=466(423); /POSITIVE=300(257); /UNKNOWN=25(25); BH /F_P=141(141); /F_N=136; /P=4; CC /TAX=!?; /MAX-R=2; CC /VER=2; RW P9610, AR_BSU , T; PAE25, AE_E57... (10 Replies)
Discussion started by: redse171
10 Replies

3. Shell Programming and Scripting

Extract line between two patterns

Hi All, I need a script to extract a lines between two patterns.I have done this using grep,cut,tail and head.But its very slow, because my input file contain more than a lakh. COMMAND:XXXXXXXXXXXXXXXXXXXX yyyyy zzzzzz REQUESTSTRING:aaaaaaaaaaaaaaa;11111 222222 333333... (4 Replies)
Discussion started by: rajamohan
4 Replies

4. Shell Programming and Scripting

comment a line of the patterns is a the beginning of the line

I need to comment the lines starting with pattern "exclude" or "exclude=". If the work exclude comes at any other part, ignore it. Also, ignore, excludes, excluded etc. Ie only comment the line starting with exclude. File contents. exclude exclude= hi I am excluded excludes excludes= ... (9 Replies)
Discussion started by: anil510
9 Replies

5. Shell Programming and Scripting

print the next line by searching with different patterns

Hi, I am having an '.xml' file with 'n' number of lines and also having another file with '.txt' format contains values which i want to search. Now I want to print the next line with the pattern which i am searching in '.xml' file. And the loop has to repeat for different patterns which... (5 Replies)
Discussion started by: tejastrikez
5 Replies

6. Shell Programming and Scripting

Help with extracting a part of a line between two patterns

Hello All, I have a text file with contents as below: contents of error.txt: message1="Reason for error code1" message2="Reason for error code2" message3="Reason for error code3. To solve this, you may try doing restart" I have a requirement where in I have to... (4 Replies)
Discussion started by: asterisk-ix_use
4 Replies

7. Shell Programming and Scripting

How to get line after occurence of sequence of patterns

In the past I needed a help with the problem how to search for pattern after the occurence of another pattern which is described in this thread: https://www.unix.com/shell-programmin...-pattern1.html Now I would need something quite similar, only the pattern which is to be searched must be... (3 Replies)
Discussion started by: sameucho
3 Replies

8. Shell Programming and Scripting

Grep between 2 patterns in a line

Hi I have a file containing 1000+ lines of netlist data. I need to search for text between two key words on each line for e.g my input file has "ABC.ABC__312.deftr_0.X143.Xntys_0.\Xetabc__ABC_test_tz .X1023" "ABC.ABC__312.asjartwtsj"... (16 Replies)
Discussion started by: naveen@
16 Replies

9. UNIX for Dummies Questions & Answers

AWK: Multiple patterns per line

Hi there, We have been given a bit of coursework using awk on html pages. Without giving too much away and risking the wrath of the plagerism checks, I can say we need to deal with certain html elements. There may be several of these elements on one line. My question is, if there are more... (1 Reply)
Discussion started by: Plavixo
1 Replies

10. UNIX for Dummies Questions & Answers

searching for two or more patterns in a line

how can I search for two or more patterns in one line using grep? for example if I want to show only the lines that have patterns "abc" and "123"? and what if I want to show only the lines that have either "abc" or "123" in them? any hint apprecited (4 Replies)
Discussion started by: metalwarrior
4 Replies
Login or Register to Ask a Question