Solved

Search for specific file content

Posted on 2014-09-15
7
378 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, EE MVE
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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, EE MVE
Gerwin Jansen, EE MVE 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linux tcp ports listening for testing 4 65
nagios 4 php error after installation 6 95
VMware Workstation 12 Player 16 76
winscp 000webhost.com 6 54
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
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.

832 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