Skip to content

Instantly share code, notes, and snippets.

@fabiochelly
Last active June 12, 2022 21:09
Show Gist options
  • Save fabiochelly/4b19474f64be28a11a4de7b1a94e4261 to your computer and use it in GitHub Desktop.
Save fabiochelly/4b19474f64be28a11a4de7b1a94e4261 to your computer and use it in GitHub Desktop.
# Find a file
`find . -name <filename>` # Find all files in current dir and subdirs
`find . -type d -name <filename>` # Find all files matching this name
`find . -mtime -1 -name "*.php"` # Find all PHP files modified in the last 24h
`find . -mtime -2 -name "*.php"` # Find all PHP files modified in the last 48h
`find . -size +500000k` # Find all files with size > 500MB
`grep --include=\*.php -rnw . -e "b374k"` # Find all PHP files containing "b374k"
# Counting files
find . -name *.jpg | wc -l # Counts all JPG files in current dir
find . -name \*.jpg -or -name \*.png | wc -l
# Counts files and dirs in current dir (including subdirs)
for t in files links directories; do echo `find . -type ${t:0:1} | wc -l` $t; done 2> /dev/null
# Count files and dirs in current dir (without subdirs)
for t in files links directories; do echo `find . -maxdepth 1 -type ${t:0:1} | wc -l` $t; done 2> /dev/null
# Calculate size of dirs
`du -chs` # Complete size of current dir
`du -chs ./*` # Size of all dirs and files in current dir (no subdir)
`du -cs ./* | sort -n` # same sorted by size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment