Find *.java file but ignore test file such as TestA.java or ATest.java file:
find . -type f \\( -iname "*.java" ! -iname "*Test*" \\)
grep -r "String" --include=*.java .
find . -name "*.java" -exec grep "String" {} \\;
-l: show file name only
grep -rl "java.util.regex" * | wc -l
grep interpret search patterns as basic regular expressions.
use -E to interpret patterns as extended regular expressions
Difference between basic and extended regular expressions is that:
in basic regular expression, the meta-characters ?, +, {, |, (, and ) are interpreted as literal characters. To keep their special meaning, the character must be escaped with a backslash(\)
-A 1
option will give you one line after;
-B 1
will give you one line before;
-C
combines both to give you one line both before and after