Find multiple string in one file using find command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find multiple string in one file using find command
# 1  
Old 09-29-2011
Find multiple string in one file using find command

Hi,
I want find multiple string in one file using find coomand.
And keeping it in one variable.grep is not working.
# 2  
Old 09-29-2011
Code:
$ variable=`egrep "string1|string2|string3" infile`

# 3  
Old 09-29-2011
Code:
grep -e 'string1|string2' file

# 4  
Old 09-29-2011
put multiple pattern in one file ( a.txt)

and use fgrep
# 5  
Old 09-29-2011
Quote:
Originally Posted by itkamaraj
put multiple pattern in one file ( a.txt)

and use fgrep
Probably you are talking about grep -f ?
fgrep is equivalent to grep -F. However both can be used together.

Sorry if you were trying to say something else which I misunderstood.
# 6  
Old 09-29-2011
yes, i am talking about the
HTML Code:
fgrep
which is
HTML Code:
grep -F
because vivek wants to search for multiple string
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can I use find command to search string/pattern in a file recursively?

Hi, How can I use find command to search string/pattern in a file recursively? What I tried: find . -type f -exec cat {} | grep "make" \; Output: grep: find: ;: No such file or directory missing argument to `-exec' And this: find . -type f -exec cat {} \; -exec grep "make" {} \;... (12 Replies)
Discussion started by: cola
12 Replies

2. Shell Programming and Scripting

Find string in file and find the all records by string

Hello I would like to get know how to do this: I got a big file (about 1GB) and I need to find a string (for instance by grep ) and then find all records in this file based on a string. Thanks for advice. Martin (12 Replies)
Discussion started by: mape
12 Replies

3. Shell Programming and Scripting

Help with Passing the Output of grep to sed command - to find and replace a string in a file.

I have a file example.txt as follows :SomeTextGoesHere $$TODAY_DT=20140818 $$TODAY_DT=20140818 $$TODAY_DT=20140818I need to automatically update the date (20140818) in the above file, by getting the new date as argument, using a shell script. (It would even be better if I could pass... (5 Replies)
Discussion started by: SriRamKrish
5 Replies

4. Shell Programming and Scripting

Script to find & replace a multiple lines string across multiple php files and subdirectories

Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ? The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories. So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies

5. Shell Programming and Scripting

How to use grep & find command to find references to a particular file

Hi all , I'm new to unix I have a checked project , there exists a file called xxx.config . now my task is to find all the files in the checked out project which references to this xxx.config file. how do i use grep or find command . (2 Replies)
Discussion started by: Gangam
2 Replies

6. OS X (Apple)

how to find a string in file under multiple level dirs

Hi, i am asking a command to find a string in file(s) from multiple level directory structures. help would be really appreciated. (4 Replies)
Discussion started by: ywu081006
4 Replies

7. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

8. Linux

Simplified find command to find multiple file types

Hi, I'm using the following command to find the multiple requierd file types and its working fine find . -name "*.pl" -o -name "*.pm" -o -name "*.sql" -o -name "*.so" -o -name "*.sh" -o -name "*.java" -o -name "*.class" -o -name "*.jar" -o -name "*.gz" -o -name "*.Z" -type f Though... (2 Replies)
Discussion started by: vickramshetty
2 Replies

9. Shell Programming and Scripting

I need to find one command from multiple files and need to print that file which contains neede com

Hi all i need your help .. I am having a multiple file in directory and i have find out the Rcopy word from these files and need to print those files which contains the Rcopy word Thanks and regards Vijay sahu (2 Replies)
Discussion started by: vijays3
2 Replies

10. Shell Programming and Scripting

Looking for command(s)/ script to find a text string within a file

I need to search through all files with different file suffixes in a directory structure to locate any files containing a specific string (5 Replies)
Discussion started by: wrwelden
5 Replies
Login or Register to Ask a Question