How to find a file with specific string inside it.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to find a file with specific string inside it.
# 1  
Old 05-07-2010
How to find a file with specific string inside it.

Hi ,
Is there any way i can find a file with specific word inside it.
For example if i want to find a file which has some text written inside it.
How would i form a command to search them?
# 2  
Old 05-07-2010
Quote:
Originally Posted by pinga123
Hi ,
Is there any way i can find a file with specific word inside it.
For example if i want to find a file which has some text written inside it.
How would i form a command to search them?

Code:
# find /directory_name/where/file/resides -type f -exec grep "pattern" {} +


Last edited by Reboot; 05-07-2010 at 07:02 AM.. Reason: typo..
This User Gave Thanks to Reboot For This Post:
# 3  
Old 05-07-2010
You can also try just grep.
Code:
grep "pattern" /dir

This User Gave Thanks to jld For This Post:
# 4  
Old 05-07-2010
Thanks friends I have used following command to get my task done.
Code:
grep -r 'paternname' <location where the search should begin>

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find all .sh files in file system and need to replace the string inside .sh files

Hi All, I need to write a script to find all "*.sh" files in /home file system and if any string find "*.sh" files with the name vijay@gmail.com need to replace with vijay.bhaskar@gmail.com. I just understood about the find the command to search .sh files. Please help me on this. find / -name... (3 Replies)
Discussion started by: bhas85
3 Replies

2. UNIX for Dummies Questions & Answers

Search for a specific String in a log file for a specific date range

Hi, I have log file which rolls out every second which is as this. HttpGenRequest - -<!--OXi dbPublish--> <created="2014-03-24 23:45:37" lastMsgId="" requestTime="0.0333"> <response request="getOutcomeDetails" code="114" message="Request found no matching data" debug="" provider="undefined"/>... (3 Replies)
Discussion started by: karthikprakash
3 Replies

3. Shell Programming and Scripting

How to find a file with a specific pattern for current sysdate & upon find email the details?

I need assistance with following requirement, I am new to Unix. I want to do the following task but stuck with file creation date(sysdate) Following is the requirement I need to create a script that will read the abc/xyz/klm folder and look for *.err files for that day’s date and then send an... (4 Replies)
Discussion started by: PreetArul
4 Replies

4. Shell Programming and Scripting

read a string from its end to its start and stop when you find a specific character

How can I do this? Actually I have a file which contains a path e.g. /home/john/Music/hello.mp3 and I want to take only the filename (hello.mp3) So, I need to read the file from its end to its start till the character "/" Is this possible? Thanks, I am sure you'll not disappoint me here! Oh,... (9 Replies)
Discussion started by: hakermania
9 Replies

5. Shell Programming and Scripting

Find and replace a string a specific value in specific location in AIX

Hi, I have following samp.txt file in unix. samp.txt 01Roy2D3M000000 02Rad2D3M222222 . . . . 10Mik0A2M343443 Desired Output 01Roy2A3M000000 02Rad2A3M222222 . . (5 Replies)
Discussion started by: techmoris
5 Replies

6. UNIX for Dummies Questions & Answers

Find something inside a file

Hi, this is the problem i'm facing i need a check some file having some word like gzip or tar ,the way i normally do is grep gzip filenamethe thing is that i had some 1000 files to be checked is that the only way or can i customize it by some script ,i know there is some way ,but i need some... (4 Replies)
Discussion started by: malickhat
4 Replies

7. UNIX for Dummies Questions & Answers

cmd sequence to find & cut out a specific string

A developer of mine has this requirement - I couldn't tell her quickly how to do it with UNIX commands or a quick script so she's writing a quick program to do it - but that got my curiousity up and thought I'd ask here for advice. In a text file, there are some records (about half of them)... (4 Replies)
Discussion started by: LisaS
4 Replies

8. Shell Programming and Scripting

String substitution on find results inside exec/xargs

What I'm trying to do is perform a copy, well a ditto actually, on the results of a find command, but some inline string substitution needs to happen. So if I run this code find ./ -name "*.tif" I get back these results. .//1234567.tif .//abcdefg.tif Now the action from exec or xargs I... (2 Replies)
Discussion started by: myndcraft
2 Replies

9. Shell Programming and Scripting

How to find a string inside files

Hi, I would like to know how to get a list of files that contain a specific string inside them. Thanks (12 Replies)
Discussion started by: yoavbe
12 Replies
Login or Register to Ask a Question