Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. root@vps [~/testinggrounds]# cat md5.txt | while read a b; do
  2. > md5sum "$b" | read c d
  3. > if [ "$a" != "$c" ] ; then
  4. > echo "md5 of file $b does not match"
  5. > fi
  6. > done
  7. md5 of file file1 does not match
  8. md5 of file file2 does not match
  9.  
  10. root@vps [~/testinggrounds]# md5sum file*
  11. 2a53da1a6fbfc0bafdd96b0a2ea29515 file1
  12. bcb35cddc47f3df844ff26e9e2167c96 file2
  13.  
  14. root@vps [~/testinggrounds]# cat md5.txt
  15. 2a53da1a6fbfc0bafdd96b0a2ea29515 file1
  16. bcb35cddc47f3df844ff26e9e2167c96 file2
  17.  
  18. -c, --check
  19. read MD5 sums from the FILEs and check them
  20.  
  21. $ ls
  22. 1.txt 2.txt md5.txt
  23. $ cat md5.txt
  24. d3b07384d113edec49eaa6238ad5ff00 1.txt
  25. c157a79031e1c40f85931829bc5fc552 2.txt
  26. $ md5sum -c md5.txt
  27. 1.txt: OK
  28. 2.txt: OK
  29.  
  30. while read -r -u3 sum filename; do
  31. read -r cursum _ < <(md5sum "$filename")
  32. if [[ $sum != $cursum ]]; then
  33. printf 'md5 of file %s does not matchn' "$filename"
  34. fi
  35. done 3<md5.txt
  36.  
  37. #! /bin/bash
  38.  
  39. cat md5.txt | while read sum file
  40. do
  41. prev_sum=$(md5sum $file | awk '{print $1}')
  42. if [ "$sum" != "$prev_sum" ]
  43. then
  44. echo "md5 of file $file does not match"
  45. else
  46. echo "$file is fine"
  47. fi
  48. done
  49.  
  50. md5sum "$b" | read c d
  51.  
  52. c=`md5sum "$b" | cut -d " " -f 1`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement