diff --git a/.config/zsh/zshrc.d/40-functions.zsh b/.config/zsh/zshrc.d/40-functions.zsh index abe5193..f5d745c 100644 --- a/.config/zsh/zshrc.d/40-functions.zsh +++ b/.config/zsh/zshrc.d/40-functions.zsh @@ -554,15 +554,17 @@ suffix() { finddup() { # find all files, filter the ones out with unique size, calculate md5 and # print duplicates + # TODO: Fix duplicate lines output in the awk script that currently `sort + # -u` handles find "$@" -type f -exec du '{}' '+' \ - | awk '{print $2,$1}' \ - | sort -k2 \ - | uniq -f1 -D \ - | awk '{print $1}' \ + | sort \ + | awk '{ if (!_[$1]) { _[$1] = $0 } else { print _[$1]; print $0; } }' \ + | sort -u \ + | cut -d$'\t' -f2- \ | xargs -d'\n' md5sum \ | sort \ | uniq -w32 --all-repeated=separate \ - | awk '{print $2}' + | cut -d' ' -f3- } # Wrapper around tmsu that searches for .tmsu/db in all parent directories and