Find file and Find text in files on Linux

Find file

Find file by file name or extension

cd /where-to-find/

find . -name "filename*"

find . -name "*.txt"

Find TEXT in files

Search text "java"
- Recursive (-r)
- Print the filename (-H)
- Ignore case (-i)

cd /where-to-find/
grep -H -r "java" .

Only search text "java" in .txt files

cd /where-to-find/
grep -irH 'java' *.txt

Loading