Created
March 25, 2015 16:34
-
-
Save gravesm/6bfbc3b895e34adcea44 to your computer and use it in GitHub Desktop.
dedup
This file contains 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
#!/usr/bin/env bash | |
#### | |
# ./dedup FROM TO | |
# | |
# move duplicate emails from FROM to TO | |
#### | |
duplicates=$(grep --no-filename -rE "^To:\s[[:alpha:]]+" $1 | sort | uniq -c | \ | |
grep -E "[[:blank:]]([2-9]|[[:digit:]]{2,})" | cut -d : -f 2) | |
for i in $duplicates | |
do | |
n=0 | |
for f in $(grep -rl "To: $i" $1) | |
do | |
if [ $n -gt 0 ] | |
then | |
mv "$f" "$2" | |
fi | |
n+=1 | |
done | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment