My build of nnn with minor changes
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

45 řádky
1.2 KiB

  1. #!/usr/bin/env sh
  2. # Description: List non-empty duplicate files in the current directory (based on size followed by MD5)
  3. #
  4. # Source: https://www.commandlinefu.com/commands/view/3555/find-duplicate-files-based-on-size-first-then-md5-hash
  5. #
  6. # Dependencies: find md5sum sort uniq xargs
  7. #
  8. # Note: bash compatible required for mktemp
  9. #
  10. # Shell: bash
  11. # Authors: syssyphus, KlzXS
  12. # If the size of a file has more that $size_digits digits the file will be misplaced
  13. # 12 digits fit files up to 931GiB
  14. EDITOR="${EDITOR:-vi}"
  15. TMPDIR="${TMPDIR:-/tmp}"
  16. size_digits=12
  17. tmpfile=$(mktemp "$TMPDIR/.nnnXXXXXX")
  18. # shellcheck disable=SC2016
  19. find . -size +0 -type f -printf "%${size_digits}s %p\n" | sort -rn | uniq -w"${size_digits}" -D | tr '\n' '\0' | xargs -0 -n1 sh -c 'printf "%s %s\n" "$(md5sum $@)" "d$0"' | sort | { uniq -w32 --all-repeated=separate; echo; } | sed -nE '
  20. h
  21. s/^(.{32}).* d([0-9]*)$/md5sum: \1 size: \2 bytes/p
  22. g
  23. :loop
  24. N
  25. /.*\n$/!b loop
  26. p' | sed -E 's/^.{32} (.*) d[0-9]*$/\1/' > "$tmpfile"
  27. "$EDITOR" "$tmpfile"
  28. cat "$tmpfile"
  29. # shellcheck disable=SC2016
  30. sed -e 's/md5sum.*//' "$tmpfile" | tr '\n' '\0' | xargs -0 sh -c 'rm -i $0 $@ < /dev/tty'
  31. rm "$tmpfile"
  32. printf "Press any key to exit"
  33. read -r _