Terminal - Files Flashcards
Find files which have been modified today
find . -mtime -1 -print
Find all backup files in a directory
find . -name *~ -print
Find all backup files and delete them!
find . -name “*~” -exec rm {} \;
Change permissions for all folders only
find . -type d -exec chmod g+x {} \;
Set the group id bit (so files created later in the folder belong to the folder’s group)
chmod g+s directory
Uncompress lots of zips with just one line of terminal commands
find *.zip -exec unzip {} \;
Find only files
find . -type f
Find only files … and delete them!
find . -type f -delete
Recursively find files which contain a given text
grep -lir “a given text” *
Find in files but do not search in .git directories
grep -Ir –exclude-dir=”.git” “pattern” *
Move files from nested folders to current directory (“un-nest” them)
find . -type f -exec mv {} . \;
Available space in disk
df -h
Show differences between two files without taking into account whitespace (very useful when line returns and spaces/tabs are messing up normal diffs)
diff -w file1 file2
Get the md5 hash of a file
md5sum filename
Meaning of:
find . -mtime -1 -print
Find files which have been modified today