Last active
December 15, 2015 17:49
-
-
Save samba/5298817 to your computer and use it in GitHub Desktop.
Shell tricks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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