I have a server which runs on centos 7. I need to find a file containing 0774386850 so that I can replace with another string. Kindly give me a Linux command to give me that file
Asked
Active
Viewed 2.4k times
11
-
1Possible duplicate of [How do I find all files containing specific text on Linux?](https://stackoverflow.com/questions/16956810/how-do-i-find-all-files-containing-specific-text-on-linux) – dlmeetei Aug 07 '17 at 10:39
-
1Did you put someone's mobile number in your question?... – Attie Aug 07 '17 at 10:56
3 Answers
22
By using grep
command, you can achieve what you expected
grep -rlnw '/path/to/somewhere/' -e '0774386850'
-r or -R is recursive,
-n is line number, and
-w stands for match the whole word.
-l (lower-case L) file name of matching files.

ntshetty
- 1,293
- 9
- 20
0
You can use either grep/fgrep or find to achieve your goal.

tibetty
- 563
- 2
- 10
-
find /path/to/files -type f -exec sed -i 's/oldstring/new string/g' {} \; – tibetty Aug 07 '17 at 10:40