How to search multiple word using grep command?


 
Thread Tools Search this Thread
Operating Systems Linux How to search multiple word using grep command?
# 1  
Old 05-14-2014
How to search multiple word using grep command?

How to search multiple word using grep command
for example i want to reserch
Code:
ANJ001
AA

Moderator's Comments:
Mod Comment Using ridiculous font, size, and color changes instead of normal space separated text and CODE tags obfuscates what you are trying to do and makes it difficult for volunteers who may want to help you solve your problems.

Last edited by Don Cragun; 05-14-2014 at 02:14 PM.. Reason: Replace posting with less obfuscated text.
# 2  
Old 05-14-2014
try
Code:
grep "ANJ001.*AA" filename # if you want both words
egrep -i 'ANJ001|AA' filename # if want either of the word

1 Question:Why you have ask question in such a font and without spaces..

Last edited by Makarand Dodmis; 05-14-2014 at 07:44 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep multiple exact word

Hi I am trying to grep multiple exact word from log file and directing it to a new file. however my log file has many numeric values, such as 0400, 0401, 0404 and all html error also starts with 404, 401 etc so I just want to grep only when 404, 401 etc is coming, NOT 0400, OR 0401 i have... (8 Replies)
Discussion started by: scazed
8 Replies

2. 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

3. Solaris

How to search for a word in multiple files

Hi, I want to find for a particular word which is existing in different files and folders under the parent directory. What command can I use to retrieve all the file names which is having the word. (1 Reply)
Discussion started by: rogerben
1 Replies

4. Shell Programming and Scripting

Grep Search for both First and last word

Hi Pretty sure this is very simple hence im banging my head o the wall as to why i cant get this to work: Im greping against many files where there will be the following string: Date: Thu, Aug 23 2001 09:27 PM (of course values such as date ,time and PM/AM will vary.) Im trying to grep... (1 Reply)
Discussion started by: duonut
1 Replies

5. UNIX for Advanced & Expert Users

word search in multiple directories

need a Command in UNIX which can find out a word from files in multiple directories e.g. /home contains multiple directories /home/d1 /home/d2 . . . . /home/dn under d1,d2...dn contains multiple files. I need to search a specific word in a files under these multiple... (1 Reply)
Discussion started by: jagkoth
1 Replies

6. Shell Programming and Scripting

Grep word search

Hi, I have grep command to search for a word "SUB" as below, grep -w "SUB" file1 But this is taking a word like SUB.XXY or SUB.BBB etc which is not required.. I need only if it is a word "SUB". Any suggestions ??? Thanks, Vasanth. (11 Replies)
Discussion started by: skcvasanth
11 Replies

7. Shell Programming and Scripting

can anyone help with shell script command about searching word with grep command?

i want to search in the current directory all the files that contain one word for example "hello" i want to achieve it with the grep command but not with the grep * (2 Replies)
Discussion started by: aintour
2 Replies

8. Shell Programming and Scripting

grep multiple patterns + the whole word only

Guys, i used egrep "pattern1|pattern2". But the whole word is searched. But i want the output if only the exact word is matched. i.e the output is got evenif a part of the pattern is matched. I tried the -w opion but its showing usage error. Please help me out on this one. please sent me... (2 Replies)
Discussion started by: meheretoknow
2 Replies

9. Shell Programming and Scripting

grep -w Search for the expression as a word

I have a file (file1) with around 5000 records and another file (file2) with 50000 records. I want to search each word in file 1 from file 2 and spew the output of the matches in file3. Can someone please help me here. I tried doing this in ksh for i in `cat file1` do grep -w $i... (15 Replies)
Discussion started by: knijjar
15 Replies

10. Shell Programming and Scripting

multiple search with grep

is it possible to execute multiple search with grep??? grep criteria1 criteria2 file something like this... I know other way: grep pattern1 file-name1 > results-file grep pattern2 file-name1 >> results-file cat results-file but can it be done with one grep???? (5 Replies)
Discussion started by: amon
5 Replies
Login or Register to Ask a Question