Solved

Search for specific file content

Posted on 2014-09-15
7
377 Views
Last Modified: 2014-09-15
I would like to do a search to  list  all files that have a particular set of words contained in them, i.e., "digital brochures". I do not want it to be case sensitive.  I would like to do the search of all files in the current directory plus all its subdirectories.

Thank you.
0
Comment
Question by:geeta_m9
  • 3
  • 2
  • 2
7 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 400 total points
ID: 40323893
grep -R -i -l "digital brochures" .

Note the dot " ." at the end!

The above will list just filenames with matching content, not the content itself. To see the content along with the filename, omit "-l".
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40323906
Do you want the order specified as well like "digital brochures" or do you want all files that contain both words (anywhere in the file)?
0
 

Author Comment

by:geeta_m9
ID: 40323921
No, I want it in that order for this purpose. For academic purposes, let's say I wanted it the way you suggested. How would the command be modified?
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:geeta_m9
ID: 40323927
When I enter the command grep -R -i -l "digital brochures",  the cursor just seems to be stuck in one spot. Does this command take a long time to execute?
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 40323930
You forgot to type the dot "." at the end. See the note in my first comment!

To your academic question:

grep -E -R -i -l "digital|brochures" .

"-E" means "Interpret the pattern as an extended regular expression", and
the vertical bar ("pipe") means "or".
0
 
LVL 37

Assisted Solution

by:Gerwin Jansen
Gerwin Jansen earned 100 total points
ID: 40323944
>> Does this command take a long time to execute?
Depending on how much files you have, yes it can...

grep -iR -l "digital" . 2>/dev/null | xargs grep -iR -l "brochures" 2>/dev/null
0
 

Author Comment

by:geeta_m9
ID: 40323946
Yes, that was the problem. Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linux Scripting 3 102
AWS CLI - Issue with name display 2 51
Steps to follow for Maintenance of Servers 4 53
Error Message during CentOS 7 Minimal Install 3 34
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

920 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

17 Experts available now in Live!

Get 1:1 Help Now