Solved

Search for a file using content criteria

Posted on 2004-10-08
5
261 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

914 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

16 Experts available now in Live!

Get 1:1 Help Now