Search

Search for files

# Find files by name
find filename.txt

# Find all files over 100 KB
find * -size +100k

# Find total size of folder + subdirectories + files
du -sh

# Find files modified in last 24 hours
# current dir and subduers
find . -mtime -1 -print

Resources

Search for text

# Find text in files (recursive + show line output)
grep -r "string" *

# Find text in files (recursive + suppress line output)
grep -rl "string" *

# Find text in files (recursive + show line output + show line numbers)
grep -rn "string" *

# Find all files with additions in DIFF
grep '+++' filename.diff

# Find all files with additions in DIFF
grep '---' filename.diff

Search and replace text

# Replace 'red' with 'blue'
find . -name '*.css' -print0 -o -name '*.html' -print0 -o -name '*.js' -print0 -o -name '*.php' -print0 -o -name '*.phtml' -print0 -o -name '*.xml' -print0 | xargs -0 sed -i '' 's/red/blue/g'

Resources