All pastes #184055 Raw Edit

uniqfile [1]

public shellscript v1 · immutable
#184055 ·published 2006-09-27 14:36 UTC
rendered paste body
#!/bin/sh# This bash script, locates unique files using md5sum,# and stores only one instance into another folder that# the user specifies as an argument.usage() {	echo "Description:"	echo "Identifies unique files by using md5sum "        echo "and then copies them into a dirctory."	echo	echo "Usage: uniqfile [DIR]"	echo	echo "[DIR] is the path of the directory you  "	echo "wish to backup your files               "	echo 	echo "Command line arguments are not optional."}if [ "$1" = "-h" -o "$1" = "--help" ]; then	  usage	    exit 0   elif [ -z "$1" ]; then    echo "Invalid arguments."	exit 0    		else	    directory=$1fiecho "Calculating md5..."files=$(md5sum * 2>/dev/null | sort -n | uniq --check-chars=32 | cut -d" " -f3)echo "Copying the files..."cp $files $directoryecho "Done."exit