11

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

dlmeetei
  • 9,905
  • 3
  • 31
  • 38
Peter Mutai
  • 133
  • 1
  • 1
  • 7
  • 1
    Possible 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
  • 1
    Did you put someone's mobile number in your question?... – Attie Aug 07 '17 at 10:56

3 Answers3

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
3

grep -r "0774386850 " /path/to/dir

Hosain Ahmed
  • 115
  • 6
0

You can use either grep/fgrep or find to achieve your goal.

tibetty
  • 563
  • 2
  • 10