Last active
January 4, 2016 02:39
-
-
Save matherton/8556786 to your computer and use it in GitHub Desktop.
Bash script to find unlinked files in a directory
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
| MYPATH=$1 | |
| find "$MYPATH" -name *.jpg -exec basename {} \; > /tmp/patterns | |
| find "$MYPATH" -name *.jpeg -exec basename {} \; >> /tmp/patterns | |
| find "$MYPATH" -name *.png -exec basename {} \; >> /tmp/patterns | |
| find "$MYPATH" -name *.gif -exec basename {} \; >> /tmp/patterns | |
| find "$MYPATH" -name *.css -exec basename {} \; >> /tmp/patterns | |
| find "$MYPATH" -name *.js -exec basename {} \; >> /tmp/patterns | |
| find "$MYPATH" -name *.php -exec basename {} \; >> /tmp/patterns | |
| for p in $(cat /tmp/patterns); do | |
| grep -R $p "$MYPATH" > /dev/null || echo $p; | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
save as unlinked.sh change to an executable file and run from terminal:
$ chmod +x unlinked.sh
$ ./unlinked.sh