I want to use grep to find the lines contain String in all java files under current directory.
I tried:
grep -r "String" **/*.java But it doesn't work:
grep : **/*.java: no such file or directory How to write it?
UPDATE
I'm on windows, using the grep provided by unxUtils, which doesn't support --include parameter. Is there any other way?
To include all subdirectories in a search, add the -r operator to the grep command. This command prints the matches for all files in the current directory, subdirectories, and the exact path with the filename.
Grep command is used to search text from files. It is a versatile pattern that invokes grep with –r. –R option search files recursively from subdirectories, starting from the current directory. The command is run from the top-level directory.
You can use grep tool to search recursively the current folder, like: grep -r "class foo" .
Use recursive grep:
grep -r "String" --include=*.java .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With