Find Files and Text

Find Files

Find png files recursively (current directory and sub-directories) and sort by path:

$ find . -name "*.png" | sort

Filter files having "deb" in file name ignoring text case and within current directory:

$ find . -maxdepth 1 -type f -iname "*deb*"

Count files with "AA" in name:

$ find . -maxdepth 1 -type f -name "*AA*" | wc -l

25 simple examples of Linux find command - BinaryTides

Find Text

Find "update" in all files recursively and show line number:

$ grep -r --color -n "update" *

Find "Debian" in html and md files:

$ grep -r --color -n --include="*.{html,md}" --exclude-dir=.git "Debian" *

Find "Google" excluding files "*hosts.txt" and directory "img":

$ grep -r --color -n --exclude-dir="img" --exclude="*hosts.txt" "Google" *

zgrep can search in gz-files:

# zgrep -n "firefox" /var/log/apt/history.log*