Friday, May 21, 2010

How do I find files with some known contents in Linux?

I want to find all the files in the current directory that contain the expression 'WhichFilesAmIIn'. How do I do this if I need to use Linux?


I know the 'find' command can be used to find files but, as far as I know, I can only give some expressions for the file names and not what's inside.

How do I find files with some known contents in Linux?
dude, I want to know this too. It's been annoying me for ages. Will hang around...





... ok if the Penguin says it, it must be true. I vote for that guy.
Reply:simple !!





grep keyword *





or





cat * | grep keyword
Reply:to view contents of files in current directory use the command "cat"


the syntax would be


cat (file name)
Reply:The command you want is grep. Use it like this:


grep -r WhichFilesAmIIn *


From the directory you want to start looking and it will tell you the file name and show you the line that the term is in.


This will only work with text based files. Binary files is much more difficult to do.


No comments:

Post a Comment