Skip to content

Instantly share code, notes, and snippets.

@samba
Last active December 15, 2015 17:49
Show Gist options
  • Select an option

  • Save samba/5298817 to your computer and use it in GitHub Desktop.

Select an option

Save samba/5298817 to your computer and use it in GitHub Desktop.
Shell tricks
#!/bin/sh
# Show duplicate files (compared by MD5 hash)
find ./ -type f -print0 | xargs -0 md5sum | sort | uniq -w 32 -D
# Remove smart-quotes from a buffer/file
sed "s/[”“]/\"/g; s/[’‘]/'/g"
# Rename a series of files (e.g. restore backups) by regular expression in OS X
find ./ -type f -name '*.bak' -print | sed -E 's/(.*)\.bak$/mv "&" "\1"/' > rename.sh
# Remove lines matching an expression from all files in a directory
find ./ -type f -print0 | xargs -0 grep -l foldmarker | xargs sed -i .bak -E '/foldmarker/d'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment