find, search, grep
find
use cases:
find ./subfolder -name sample.txt- Search a file with specific namefind ./subfolder -name *.txt- Search a file with patternfind ./GFG -name sample.txt -exec rm -i {} \;- find and delete a file with confirmationfind ./subfolder -empty- Search for empty files and directoriesfind ./subfolder -perm 664- Search for file with entered permissionsfind ./ -type f -name "*.txt" -exec grep 'some Phrase' {} \;- Search text within multiple files
more examples
find /path -name *.txt
find /path -type f -name test.txt
find /path -name failed*.* -type f
find /path -type f -not -name "*.html"
find / -name "file.txt" -size +4M
find /dev/ -type b -name "sda*"
find ./*file*
grep
grep [OPTION]... PATTERNS [FILE]...
- options
-B <numb>- show numb lines before match-A <numb>- show numb lines after match-i- ignore case distinctions in patterns and data-r,--recursive- like --directories=recurse-v,--invert-match- To display only the lines that do not match a search pattern--exclude-dir=<foldername>- exclude folder from search
examples
grep -ir --exclude-dir=vendor skeleton .- find all occurences of "skeleton" in the current working dirgrep -i "some string" path/**/files.log- search string in log files