Modify shar to include in the archive the character count for each file and commands to compare the count of each extracted file against the count of the original file. If a discrepancy occurs, output an appropriate error message.
What will be an ideal response?
echo "#"
echo "# To restore, type sh archive"
echo "#"
for file
do
if [ -d "$file" ]
then
echo "if [ ! -d $file ] ; then"
echo " echo Making directory $file"
echo " mkdir $file"
echo "fi"
for subfile in $file/*
do
echo "echo Extracting file $subfile"
echo "cat > $subfile <<\THE-END-OF-DATA"
cat $subfile
echo "THE-END-OF-DATA"
chars=$( wc -c < $subfile )
echo "if [ \$(wc -c < $subfile) -ne $chars ] ; then"
echo " echo error: file $subfile should have $chars characters"
echo "fi"
done
else
echo "echo Extracting $file"
echo "cat >$file <<\THE-END-OF-DATA"
cat $file
echo "THE-END-OF-DATA"
chars=$( wc -c < $file )
echo "if [ \$(wc -c < $file) -ne $chars ] ; then"
echo " echo error: file $file should have $chars characters"
echo "fi"
fi
done
You might also like to view...
Which of these functions does not support multiple conditions?
A) MATCH B) AND C) NOT D) OR
Each ________ in the LDAP inverted tree is uniquely identified by a distinguished name (DN) that defines the complete path from the top of the tree to the object
a. Protocol b. Object c. Branch d. Control