• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • Last Modified:

Search for a file using content criteria

I have a newbie question. How do you search for a file(s) using their contents as the criteria?
0
DBDevOne
Asked:
DBDevOne
  • 3
  • 2
1 Solution
 
ddunleaCommented:
man grep

specifically,

grep "string to search for" files_to_search
0
 
DBDevOneAuthor Commented:
Thank you what if you don't know the file name though? Do you just put a wildcard on the end? Do you need to be in the directory of the file when you run this command or does it search everywhere
0
 
ddunleaCommented:
Use -r for recursive so specifying

grep "text" -r *

Will search all of the files starting in the current directory and working down.
0
 
DBDevOneAuthor Commented:
Nice job mister!!! Thank you.
0
 
ddunleaCommented:
No problem.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now