Skip to content

Instantly share code, notes, and snippets.

@infinite-Joy
Created June 9, 2017 04:09
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 infinite-Joy/3f976616064d6e03fa07af4c3d19a871 to your computer and use it in GitHub Desktop.
Save infinite-Joy/3f976616064d6e03fa07af4c3d19a871 to your computer and use it in GitHub Desktop.
function last_difference
{
grep -n "${pattern}" "${parse_file}" \
| tail -1 | awk '{print $1}' |\
cut -d ":" -f1
}
function all_differences
{
cat "${parse_file}" | awk 'NR>="$(last_difference)"'
}
function duplicates
{
echo "" > _tmp_dup.txt
while read x; do
# take only the paths
echo "${x}" | awk '{print $3}' >> _tmp_dup.txt
done
# get only the duplicates
cat _tmp_dup.txt | awk '++A[$1]==2'
}
function only_once
{
diff <(all_differences | awk '{print $3}' | uniq )\
<(all_differences | duplicates)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment