How to search all sub-directories for a file or command line in a file in Ubuntu?
Hello--
I'm trying to locate a file or a command line in a file on my hard drive. I am running Ubuntu 12.05.4 linux. Is there a grep command that will search the whole tree from root down to all the sub-directories? Thank You. |
grep searches the contents of files, it doesn't search for files.
Code:
$ locate name_of_file Cons: Relies upon a database which is updated daily. Code:
$ find / -type f -name name_of_file Cons: The more files you have the slower it probably is. Assuming you have some idea where the file is replace / with something else Code:
$ man find |
If you want to search for a specific line inside a file, you can use grep
Code:
grep -r line / |
Thank you!!
|
All times are GMT -5. The time now is 04:04 PM. |