#!/bin/sh -u # Sample solution to Exercise #6 #------------------------------------------------------- # Your assignment label would go here. #------------------------------------------------------- # -IAN! idallen@idallen.ca # Use a standard search path and umask for the commands in this script. # (All scripts must set PATH and umask so that they always work properly.) # PATH=/bin:/usr/bin export PATH umask 022 # Create a new temporary directory and make it the current directory. # We will extract some tar files into this directory. # mkdir newdir cd newdir # Copy the hidden tar file from the instructor to the current directory. # Run wc on the tar file to show that it copied correctly. # Expand the tar file and remove it. # Show that there are now 3 files in the current directory. # cp -p ~idallen/public_html/teaching/dat2330/03f/notes/.exercise06.tar my.tar wc my.tar tar xpf my.tar rm my.tar ls | wc # We already determined that files part2 and part3 are more tar files. # Expand these two tar files and delete them. # Run a word count on the directory to show how many files it contains. # Run a second count to show how many files start with the letter 'x'. # tar xpf part2 tar xpf part3 rm part[23] ls | wc ls x* | wc # Many of the files are not readable; fix all the permissions. # Concatenate all 816 files, in order, into a new JPEG image file. # Run wc and sum to verify the size and content of the new file. # chmod +r * cat part1 x* >tux.jpg wc tux.jpg sum tux.jpg # Remove the 816 files and leave behind the tux.jpg file. # (The "-f" stops "rm" from prompting.) # Move the tux.jpg file up to the parent directory. # rm -f part1 x* mv tux.jpg .. # Optional - tidy up by removing the (empty) temporary directory. # cd .. rmdir newdir