Test bz2 files
This page was last updated on July 18, 2009.
Here are two scripts for testing your .bz2 files. One runs fully as a command line script. The other runs kdialog – a GUI program.
Command Line
#!/bin/bash ################## # TEST BZ2 FILES # ################## # ASKS WHERE BZ2 FILES ARE KEPT. echo echo "What is the path to the bz2 files? Example: /home/$USER" echo # READS YOUR REPLY. read bz2directory echo # TELLS YOU THAT IT'S TESTING THE BZ2 FILES. echo "Testing bz2 files - please wait..." echo # PERFORMS THE TEST. bzip2 -tv $bz2directory/*.bz2 # ABORTS IF BZ2 FILES ARE NO GOOD. if [ $? != "0" ] ; then echo "The bz2 test failed - aborting script!" exit 1 fi echo # LETS YOU KNOW IT'S FINISHED. echo "Done! Your bz2 files are good!"
GUI
#!/bin/bash # THIS FILE WAS CREATED BY FRANK PIRRONE. # ANNOUNCES SCRIPT ACTION kdialog --msgbox "This script will verify bz2 files in a directory you choose." # USER SELECTS DIRECTORY kdialog --getexistingdirectory * > /tmp/bz2_test_dir # POPUP ANNOUNCES CHECKING - PERSIST 2 SECONDS kdialog --passivepopup "checking bz2 files" 2 # BZIP2 PERFORMS VALIDITY TEST bzip2 -tv `cat /tmp/bz2_test_dir`/*.bz2 # READ STDERR AND ABORT IF TEST FAILS if [ $? != "0" ] ; then kdialog --msgbox "The bz2 test failed - aborting script!" exit 1 fi # OTHERWISE ANNOUNCE SUCCESSFUL CHECK kdialog --msgbox "Done! Your bz2 files are good!" # CLEAN UP TEMP FILE rm -f /tmp/bz2_test_dir
Obligatory Happy Ending
And they all lived happily ever after. The end.

Comment: