# folder and files generated at the Seventh Session cd ${HOME}/Desktop mkdir TEST_ORIG ffmpeg -lavfi testsrc2 -t 10 -pix_fmt rgb48 -start_number 86400 TEST_ORIG/%08d.tif ## WORKING FOLDER # make a checksum manifest of the original folder # using the exercise script from the Seventh Session ... # ... otherwise this cryptic one-liner: echo "Generate checksum manifest of 'TEST_ORIG' (at origin)." #### for fun #### find TEST_ORIG -type f -exec md5sum {} + | sed "s#TEST_ORIG/*##" > correct_folder.txt # copy the original folder to a working folder echo "Copy 'TEST_ORIG' to 'TEST_WORK'." #### for fun #### cp -R TEST_ORIG TEST_WORK # verify that there are no missing files in the working folder ./script_7.sh -i TEST_WORK # make a checksum manifest of the working folder # using the exercise script from the Seventh Session ... # ... otherwise this cryptic one-liner: echo "Generate checksum manifest of 'TEST_WORK'." #### for fun #### find TEST_WORK -type f -exec md5sum {} + | sed "s#TEST_WORK/*##" > TEST_WORK_md5.txt ## BROKEN WORKING FOLDER # delete five files from the working folder echo "Delete 5 files from 'TEST_WORK'." #### for fun #### find TEST_WORK -type f | sort -R | tail -n 5 | while read f; do rm ${f}; done # verify which files are now missing in the broken folder ./script_7.sh -i TEST_WORK # update the checksum manifest of the broken folder ./script_9.sh -i TEST_WORK # make a checksum manifest of the broken folder # using the exercise script from the Seventh Session ... # ... otherwise this cryptic one-liner: echo "Generate checksum manifest of 'TEST_WORK' (missing files)." #### for fun #### find TEST_WORK -type f -exec md5sum {} + | sed "s#TEST_WORK/*##" > broken_folder.txt ## FIXED WORKING FOLDER # fix the broken folder's content by adding the missing files echo "Fix 'TEST_WORK' with files from 'TEST_ORIG'." #### for fun #### for f in $(cat TEST_WORK_missing.txt); do cp -v "TEST_ORIG/${f}" "TEST_WORK"; done # verify that no files are missing anymore in the fixed folder ./script_7.sh -i TEST_WORK # update the checksum manifest of the fixed folder ./script_9.sh -i TEST_WORK # make a checksum manifest of the fixed folder # using the exercise script from the Seventh Session ... # ... otherwise this cryptic one-liner: echo "Generate checksum manifest of 'TEST_WORK' (after fixing)." #### for fun #### find TEST_WORK -type f -exec md5sum {} + | sed "s#TEST_WORK/*##" > fixed_folder.txt ## COMPARE THE CHECKSUM MANIFESTS # show manifest differencies between original and broken folders echo "Original folder vs. broken folder:" #### for fun #### diff -s <(cat correct_folder.txt | sort) <(cat broken_folder.txt | sort) # show manifest differencies between broken and fixed folders echo "Broken folder vs. fixed folder:" #### for fun #### diff -s <(cat broken_folder.txt | sort) <(cat fixed_folder.txt | sort) # show manifest differencies between original and fixed folders echo "Original folder vs. fixed folder:" #### for fun #### diff -s <(cat correct_folder.txt | sort) <(cat fixed_folder.txt | sort)