Skip to content

Instantly share code, notes, and snippets.

@matijs
Last active December 10, 2015 18:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matijs/4475125 to your computer and use it in GitHub Desktop.
Save matijs/4475125 to your computer and use it in GitHub Desktop.
Useful command line stuff
# use `basename [suffix]` to do clever multiple renaming
for file in *.html.pdf; do \
mv "$file" "`basename $file .html.pdf`.pdf";
done
# remove "from" metadata from files on OS X
xattr -d "com.apple.metadata:kMDItemWhereFroms" file
# remove "quarantine" metadata from files on OS X
xattr -d "com.apple.quarantine" file
# kill coreaudio when redirecting audio to Apple TV stops working
sudo kill `ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}'`
# get the base64 encoded string for a file (and optionally copy it to the OS X clipboard)
openssl enc -base64 -in path/to/my/image.png | tr -d '\n' | pbcopy
# rebuild the Launch Service database (removes duplicates from the Open With contextual menu in Finder)
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
# show the last instance of a given command
!command:p
@mathiasbynens
Copy link

Uppercase all Unicode escape sequences in a JavaScript file using GNU sed:

sed -e 's/\\u\([a-fA-F0-9]\{4\}\)/\\u\U\1/g' x.js

Convert PNGs to JPEGs with medium quality:

find . -name '*.png' -type f -exec mogrify -format jpg -quality 65 {} \;

Change last-modified date to 13:37 for all files in a directory:

find . -type f -exec touch -t "$(date +'%Y%m%d1337')" {} +

@matijs
Copy link
Author

matijs commented Mar 13, 2013

Thanks @mathiasbynens :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment