Back to tools

Common examples

find

  • find . -name "*.log" - Find .log files
  • find /var/log -mtime +30 - Files modified more than 30 days ago
  • find . -size +100M - Files larger than 100MB
  • find . -type d -empty - Empty directories
  • find . -perm 755 - Files with 755 permissions
  • find . -exec rm \; - Delete all found files

grep

  • grep -r "error" . - Search "error" recursively
  • grep -i "warning" log.txt - Case insensitive
  • grep -n "failed" app.log - With line numbers
  • grep -v "INFO" log.txt - Exclude lines with INFO
  • grep -E "error|warning|critical" *.log - Extended regex
  • grep --include="*.js" "function" . - Only in .js files

Frequently Asked Questions

How do I use the find command on Linux to search for files?

The find command searches for files and directories in a hierarchy. Basic usage: find . -name "*.txt" (by name), find /var/log -mtime -7 (modified in last 7 days), find . -size +100M (larger than 100MB), find . -type f -empty (empty files). The tool lets you build these commands visually by selecting criteria without memorizing syntax.

How do I use grep to search inside files?

grep searches for text patterns inside files. Common usage: grep "error" log.txt (basic search), grep -r "TODO" . (recursive through directories), grep -i "warning" log.txt (case insensitive), grep -n "failed" *.log (with line numbers), grep -v "INFO" log.txt (exclude lines), grep -E "error|critical" *.log (extended regex for multiple patterns).

What is the difference between find and grep?

find searches for files and directories by metadata: name, size, modification date, type, permissions. grep searches for content inside files: text, patterns, regular expressions. They complement each other: find locates the files and grep analyzes their content. You can combine them with pipes: find . -name "*.log" -exec grep "error" {} \; or find . -name "*.js" | xargs grep "function".

How do I search files by name, size, and date with find?

By name: find /path -name "*.log" (wildcard) or find /path -name "access.log" (exact). By size: find . -size +500M (larger than 500MB), find . -size -1k (smaller than 1KB), find . -size 1024k (exactly 1MB). By date: find . -mtime -1 (modified in last 24h), find . -atime +30 (accessed more than 30 days ago), find . -cmin -60 (changed in last 60 minutes).