Solved

Search for a file using content criteria

Posted on 2004-10-08
5
257 Views
Last Modified: 2010-04-20
I have a newbie question. How do you search for a file(s) using their contents as the criteria?
0
Comment
Question by:DBDevOne
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:ddunlea
ID: 12259523
man grep

specifically,

grep "string to search for" files_to_search
0
 

Author Comment

by:DBDevOne
ID: 12259736
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
 
LVL 5

Accepted Solution

by:
ddunlea earned 250 total points
ID: 12259838
Use -r for recursive so specifying

grep "text" -r *

Will search all of the files starting in the current directory and working down.
0
 

Author Comment

by:DBDevOne
ID: 12259997
Nice job mister!!! Thank you.
0
 
LVL 5

Expert Comment

by:ddunlea
ID: 12260077
No problem.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In this tutorial I will explain how to make squid prevent malwares in five easy steps: Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now