I am trying to search for file contents. The file is in a directory with sub folders.
The command
grep -l 'keyword'
is working and is finding all files which are under a folder. If I am searching in a folder with subfolders, I am not getting any results.
Is there any way to search file contents using a directory level search?
You can use:
You need to do something like this:
You can also limit the find with the
-name
option and give it a shell regular expression, for example, '*.txt'.Where '.' is the current folder you're in -- you can also give any directory path instead of '.' to search a given folder.
See:
man find
This usage
grep
each file under your current directory (including subdirectories).Is that what you're looking for?
Where
./folder
is the folder you want to search