Searching file contents

Asked by Ron

Dear all,

I wonder if someone can help me find a way to search for files and file contents. I have a lot of notes and documents on my computer and I really need a way to do keyword searches for their contents.

More preferably I would need a way to do what softwares such as DevontThink Pro do for Mac users: which is an intelligent search in the contents of lots and lots of documents, pdfs, etc.

Any thoughts?

Thanks,

Ron

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

grep -R -i word /folder/to/search/*

-R = recursive
-i = case insensitive

You can change * to *.txt if you know the extension of the files ir remove recursion if the files are only in one folder. Grep is awesome

Revision history for this message
Ron (ronald17b95) said :
#2

Thanks very much for your response. Can you tell me a bit more?

Where should I insert the keyword? after *?

And how can I do a content search in a specific folder or file? Say in "Documents" folder and in a fille called "US History" or "US History.pdf"?

Thanks.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#3

grep -i word ~/Documents/US\ History.pdf

Will search the file for the word 'word'

PDFs are not a god choice for searching due to encoding text as well as the actual data. Pure text files will be much more accurate.

Revision history for this message
daniel CURTIS (anoda) said :
#4

Hi Ron. I always use 'find' command:

 $ find /home/daniel/Documents -type f -print0| xargs -0 grep -c gimp| grep -v ":0$"
 /home/daniel/Documents/allin1 for BSD/mac:3
 /home/daniel/Documents/allin1 for BSD/tips:3
 /home/daniel/Documents/tests:1

As you can see the 'gimp' word can be found in '/home/daniel/Documents/' directory and three files.

Best regards.

Can you help with this problem?

Provide an answer of your own, or ask Ron for more information if necessary.

To post a message you must log in.