search multiple words using grep


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers search multiple words using grep
# 1  
Old 08-22-2008
MySQL search multiple words using grep

Hi frnds

i want to desplay file names that should be word1 and word2

ex :

i have 10 *.log files

5 files having word1 and word2
5 files having only word1,

i have used below command

egrep -l 'word1|word2' *.log

its giving all 10 files, but i want to display only 5 files having both words
# 2  
Old 08-22-2008
Any one please give a solution.......
# 3  
Old 08-22-2008
grep for "word2" you will get the 5 files.

$ find . -name "*.log" -exec grep -l "word2" {} \;
# 4  
Old 08-22-2008
i want file names that should be word1 and word2
# 5  
Old 08-22-2008
MySQL

did you tried with the command which i given.

It will give you the filename only.
# 6  
Old 08-22-2008
i have tried but that one given file name having only word2,

but i want filenames that should be word1 and word2....
# 7  
Old 08-22-2008
i have tried with below statement,its giving a file names but some files having only 6314245093 number i.e its working like or

i am searching for &

find . | egrep -l "379400000000005|6314245093" zisfcon_080820*.log
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to use a grep search to search for a specific string within multiple directories?

Lets say I have a massive directory which is filled with other directories all filled with different c++ scripts and I want a listing of all the scripts that contain the string: "this string". Is there a way to use a grep search for that? I tried: grep -lr "this string" * but I do not... (3 Replies)
Discussion started by: Circuits
3 Replies

2. Shell Programming and Scripting

Number of words in line, while loop, search and grep

Hello, What I wish to attain is: - to read fileA line by line - search entire line as string in fileB - when found, grep the next line in fileB - then merge "searched line" and "found line" in a new file, fileC Here is my fileA: T S Eliot J L Borges L Aragon L L Aragon T S Eliot 4 0... (17 Replies)
Discussion started by: baris35
17 Replies

3. Shell Programming and Scripting

Search string or words in logs without using Grep

I'm in need of some kind of script that will search for a string in each logfile in a directory but we don't want to use GREP. GREP seems to use up to much of our memory causing the server to use up a lot of swap space. Our log files are bigger than 500M on a daily basis. We lately started... (8 Replies)
Discussion started by: senormarquez
8 Replies

4. Shell Programming and Scripting

Confused with grep for multiple words

Hi guys and gals, I have many files that contains many lines of data. I am trying to find a needle in a haystack in that I'm looking only for files that contain word1 AND word2. I'm using ... ... but this is finding files that contains word1 OR word2. No good for me. How can I grep to... (7 Replies)
Discussion started by: bbbngowc
7 Replies

5. Shell Programming and Scripting

Grep multiple words with not null value

Hi, I want to grep a file if any one (GH, IJ, KL) is not null. If it is null i dont want to pull anything. cat file | awk '{print ($1)}' Parameters are : AB=123;CD=456;EF=6789; cat file | awk '{print ($2)}' GH=456;IJ=789;KL=1011 eg: Contents in file: Parameters are :... (10 Replies)
Discussion started by: Neethu
10 Replies

6. Shell Programming and Scripting

grep - Extracting multiple key words from stdout

Hello. From command line, the command zypper info nxclient return a bloc of data : linux local # zypper info nxclient Loading repository data... Reading installed packages... Information for package nxclient: Repository: zypper_local Name: nxclient Version: 3.5.0-7 Arch: x86_64... (7 Replies)
Discussion started by: jcdole
7 Replies

7. Shell Programming and Scripting

Grep multiple words in a single file

Hello All, I'm a newbie/rookie in Shell scipting. I've done oracle export of a table using Export utility. When I do export, it generates 2 files. 1> .dmp file 2> .dmp.log file. In .dmp.log file I have to search for a sentence which goes like '0 records have been inserted' and then... (2 Replies)
Discussion started by: samfisher
2 Replies

8. Shell Programming and Scripting

grep multiple words in a single line

Hi.. How to search for multiple words in a single line using grep?. Eg: Jack and Jill went up the hill Jack and Jill were best friends Humpty and Dumpty were good friends too ---------- I want to extract the 2nd statement(assuming there are several statements with... (11 Replies)
Discussion started by: anduzzi
11 Replies

9. Shell Programming and Scripting

grep on multiple words to match text template

hi, I have few text templates as a simple ex: template 1 city Name: zip code: state Name: template2: employee Name: Phone number: I wish to grep on given text file and make sure the text file matches one of these templates. Please give your ideas. (6 Replies)
Discussion started by: rider29
6 Replies

10. UNIX for Dummies Questions & Answers

grep with find to search for matchiing words

Hi all, Please help me in the following dbt i want to know the different files in the current and the sub directory which have some search key in that . for example i want to know all filenames followed by the word 'unix' in all files. the file name and the matching word have... (1 Reply)
Discussion started by: akhil313
1 Replies
Login or Register to Ask a Question