1

Hi i have a folder which it has a lot of files.. I would like to know which file contains the number e.g. 980398123. I am in Putty and i have cd to the path containing those files.. So how do i search it using Grep.

grep 980398123 "waht to put here" 

Since I am search all the files, there will be no file name .. so waht should i put there?

Also, is there a way for me to search in within the time frame? Let say i want to grep those files contains the word within a date range?

2 Answers 2

2

you need the find command to recursively go through the directories, e.g. your current directory '.'

find . -type f -exec grep -l 980398123 {} \;

you can also use regular expressions in your grep command to search for date ranges

See:

man find , man grep

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the reply. I tried yours, "find . -type f -exec grep -l 980398123 {} \;" , But it throws Missing argument to '-exec'
0

What about * ? If you want to make the recursive seach, you need to add the -r option. So, your comand would be like this: grep -r "980398123" *

1 Comment

I tried yours.. but it said "Arguement list too long" .. failed to search

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.