I have a directory structure that looks something like this:
/home/states/Alabama
/home/states/Alaska
/home/states/Arizona
Within each state subdirectory, I have several more sub directories that look something like:
/home/states/Alabama/drink
/home/states/Alabama/food
/home/states/Alabama/fun
I want to grep for a keyword and my command looks like this:
grep -R "string" –include=*.cfg *
How can I specify the subdirectory within a state, so I only want to grep within the food directory within each state?
>Solution :
Use a wildcard to specify the path:
grep -R 'string' /home/states/*/food/*.cfg