Skip to content

Instantly share code, notes, and snippets.

@ik11235
Created November 17, 2014 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ik11235/cc3310f4fdbd1d11fc0a to your computer and use it in GitHub Desktop.
Save ik11235/cc3310f4fdbd1d11fc0a to your computer and use it in GitHub Desktop.
#!/bin/bash
trap 'rm -f "$TMPFILE"' EXIT
TARGETDIR="/home/USER/Downloads/"
TMPFILE=$(mktemp 2>/dev/null||mktemp -t tmp)
cd ${TARGETDIR}
ls . | grep -e "([1-9])" > ${TMPFILE}
while read difffile
do
echo "diff file : " ${difffile}
origifile=`echo ${difffile} | sed -e "s/ ([1-9])//"`
echo "origi file : " ${origifile}
diff -qsr "${origifile}" "${difffile}"
if [ $? -eq 0 ]; then
echo "${origifile} == ${difffile}"
echo "rm -r \"${difffile}\""
rm -r "${difffile}"
fi
done <${TMPFILE}
cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment