0

I have some .sh and .bat files in a directory. I want to list only the .sh files that has the word "JAVA_HOME".

I tried grep -rl "JAVA_HOME" | grep "*.sh", grep -rl "JAVA_HOME" *.sh and few other random things, but none of them worked. Can someone help me with this? Thank you.

3

Since you appear to be using GNU grep already (with -r), add the --include option to search only those matching filenames:

grep -rl --include='*.sh' "JAVA_HOME"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.