My build of nnn with minor changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
1012 B

  1. #!/usr/bin/env sh
  2. # Description: Create and verify md5 checksums
  3. #
  4. # If selection is used: it will generate one md5 file containing the checksums and file names
  5. # [with paths if they are in another directory]
  6. # If file is used: if the file is .md5 file, then it does the check
  7. # if the file is not .md5 file, it creates the md5 file from it
  8. #
  9. # Shell: POSIX compliant
  10. # Author: ath3
  11. selection=~/.config/nnn/.selection
  12. resp=f
  13. if [ -s "$selection" ]; then
  14. echo -n "work with selection (s) or current file (f) [default=f]: "
  15. read resp
  16. fi
  17. if [ "$resp" = "s" ]; then
  18. file=$(basename "$(cat $selection | tr '\0' '\n' | head -n 1)").md5
  19. cat "$selection" | sed 's|'"$PWD/"'||g' | xargs -0 -i md5sum {} > "$file"
  20. else
  21. if ! [ -z "$1" ] && [ -f "$1" ]; then
  22. if [ $(echo $1 | grep \.md5$) ]; then
  23. cat "$1" | md5sum -c
  24. read
  25. else
  26. file=$(basename "$1").md5
  27. md5sum "$1" > "$file"
  28. fi
  29. fi
  30. fi