how to search all files containing my target string in unix

Computer Science
Tutor: None Selected Time limit: 1 Day

how to search all files containing my target string in unix

Jul 2nd, 2015

Thank you for the opportunity to help you with your question!

  

 We  find files with Name Containing String i have been  searching for a command that will return files from the current directory which contain a string in the file name. I have seen  described and find commands that can find files beginning with something first_word* or ending with something *.jpg.

 If we have tens and thousands of text files on any Linux or Unix based server. Finding and locating those files can be done with the find command. Unfortunately find command cannot look inside a text file for a string. You have to just  need to use the grep command. The grep command searches the given input FILEs for lines containing a match or a text string.

grep command syntax:

The syntax is:

grep "text string to search” directory-path

or

grep [option] "text string to search” directory-path

or

grep -r "text string to search” directory-path

Examples:

In this example, search for a string called 'redeem reward' in all text (*.txt) files located in /home/tom/ directory, use:

$ grep "redeem reward" /home/tom/*.txt

OR

$ grep "redeem reward" ~/*.txt


To finding files containing certain strings under a directory [duplicate] case:

we tried "gerp "apple"" but it search for all the files in my Ubuntu system which takes a long time. 


http://stackoverflow.com/questions/16956810/finding-all-files-containing-a-text-string-on-linux


Please let me know if you need any clarification. I'm always happy to answer your questions.
Jul 2nd, 2015

This is great. I always use grep command after Pipe. Now I feel I know how to use it better.

thanks,

Jul 2nd, 2015

welcome it is pleasure to me that u give me a chance to do work.... I'm always happy to answer your questions..Thanks a lot

Jul 2nd, 2015

Studypool's Notebank makes it easy to buy and sell old notes, study guides, reviews, etc.
Click to visit
The Notebank
...
Jul 2nd, 2015
...
Jul 2nd, 2015
Feb 20th, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer