Skip to content

Instantly share code, notes, and snippets.

@rajeshg
Created October 23, 2010 17:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajeshg/642443 to your computer and use it in GitHub Desktop.
Save rajeshg/642443 to your computer and use it in GitHub Desktop.
Handy unix commands
# How to remove empty png files in a directory
find ./ -name "*.png" -size 0 -exec rm {} \;
# How to remove all empty files in a directory
find ./ -name "*" -size 0 -exec rm {} \;
# How to remove all .DS_Store files from a directory in Mac OS X
find . -name '*.DS_Store' -type f -delete
# How to set 755 permissions on all directories and 646 for all files
find -type d -print0 | xargs -0 -I {} chmod 755 {}
find -type f -print0 | xargs -0 -I {} chmod 646 {}
# Download and unzip a file in one line
wget http://www.mamp.info/downloads/releases/MAMP_MAMP_PRO_1.9.3.dmg.zip && unzip MAMP_MAMP_PRO_1.9.3.dmg
# List directories only
ls -d */
# restart from command line
sudo shutdown -r now # => restart now
sudo shutdown -r 1 # => restart in 1 minute
# Mount a dmg from command line
hdid <file.dmg> #eg: hdid MAMP_MAMP_PRO_1.9.3.dmg
# Number of items (files/directories) in a directory
ls | wc -w
# Shows most used commands, cool script I got this from: http://lifehacker.com/software/how-to/turbocharge-your-terminal-274317.php
alias profileme="history | awk '{print \$2}' | awk 'BEGIN{FS=\"|\"}{print \$1}' | sort | uniq -c | sort -n | tail -n 20 | sort -nr"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment