Advertisement
s243a

compare_rootfs.sh

Mar 31st, 2019
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.67 KB | None | 0 0
  1. #!/bin/sh
  2. #written by mistfire, modified by s243a
  3. #Build TazPuppy either online or local
  4. curdir=`pwd`
  5.  
  6. old='/mnt/+mnt++root+spot+Downloads+tazpuppy-5.0-beta-24.iso+puppy_tazpup_5.0.sfs'
  7. new='/root/spot/Downloads/tazpup-builder-5.13.tar.gz.extracted/tazpup-builder/slitaz-rootfs/64'
  8.  
  9. rm "$curdir/compare.log"; touch "$curdir/compare.log"
  10. rm "$curdir/compare_text_diff_size.log"; touch "$curdir/compare_text_diff_size.log"  
  11. rm "$curdir/compare_text_same_size.log"; touch "$curdir/compare_text_same_size.log"
  12. #https://stackoverflow.com/questions/9612090/how-to-loop-through-file-names-returned-by-find
  13. find "$old" -type f -print0 |
  14.     while IFS= read -r -d $'\0' f_name_full; do
  15.         f_name=${f_name_full#"$old"}
  16.         #echo "---------------"
  17.         #echo "f_name=$f_name"
  18.         if [ ! -f "$new/$f_name" ]; then
  19.             echo "$f_name" >> "$curdir/compare.log"
  20.         else
  21.            #https://unix.stackexchange.com/questions/208942/bash-script-check-if-a-file-is-a-text-file
  22.            case $(file -b --mime-type - < "$new$f_name") in
  23.              (text/*)
  24.                 old_size=$(wc -c <"$old$f_name") #https://stackoverflow.com/questions/5920333/how-to-check-size-of-a-file
  25.                 new_size=$(wc -c <"$new$f_name")
  26.                 if [ $old_size -ne $new_size ]; then
  27.                     echo "$f_name" >> "$curdir/compare_text_diff_size.log"
  28.                 else    
  29.                     echo "$f_name" >> "$curdir/compare_text_same_size.log"                
  30.                 fi
  31.                 ;;
  32.              (*)
  33.                 #echo "Not a text file"
  34.                 ;;
  35.                
  36.            esac
  37.            
  38.         fi
  39.     done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement