#!/bin/sh -u # Answer file: Exercise #2 - tuxdrinks1.sh # -Ian! D. Allen - idallen@idallen.ca # The README.txt file says: # 0. [optional] remove the directory from a previous use of this script # 1. Create a new, empty directory. # 2. Copy all the image fragment files into the new directory. # 3. Rename the damaged files to have their correct names. # 4. Concatenate all 179 fragment files into one file named image.jpg # 5. Remove all the file fragments, leaving only the image.jpg file. # 6. Display the size and checksum of the image.jpg file. # set and export standard shell search path, friendly umask # PATH=/bin:/usr/bin ; export PATH umask 022 # 0. Remove recursively any existing directory and contents. # 1. Create a new, empty directory. # 2. Copy all the image fragment files into the new directory. # rm -rf newdir mkdir newdir cp ~idallen/image/* newdir # Make the new directory our current dir to make pathnames shorter. # cd newdir # 3. Rename the incorrectly-named files to have their correct names. # mv aa mystery\ image\ fragment\ aa mv bf mystery\ image\ fragment\ bf mv "dt " mystery\ image\ fragment\ dt mv go mystery\ image\ fragment\ go mv " gw" mystery\ image\ fragment\ gw # 4. Concatenate all 179 fragment files into one file named image.jpg # 5. Remove all the file fragments, leaving only the image.jpg file. # cat mystery* >image.jpg rm -f mystery* README* # 6. Display the size and checksum of the image.jpg file. # ls -l * # or use wc sum * # To display this image on your screen in Linux: # xli image.jpg