/home2/phys210/<you>/a02
in which to store the files you submitted for the second assignment.1 You then used "chmod -R o-r" to make it and all its contents
(including any possible subdirectories and their contents)
inaccessible to o (for others).
The second step will no longer be necessary, as we have set up
a utility which periodically restores the correct
ownership, group and permissions for the
/home2/phys210/
directory tree.
This week, create /home2/phys210/<you>/a03
for your submissions on this assignment;
and so on for the rest of the course.
We won't remind you any more.
In the previous Assignment you learned how to customize your bash environment using the bash resource file .bashrc in your $HOME directory. By now you should have edited the template .bashrc file and the .aliases file it sources to suit your taste, including lots of personalized, idiosyncratic aliases that you find easier to remember (or more æsthetically pleasing) than the "raw" bash commands - which, while æsthetically offensive, are at least reasonably universal and thus worth remembering. This may impede your familiarization with bash, but for now, go ahead and indulge yourself with alias.
The goal of this Assignment is to make you reasonably familiar and comfortable with shell scripts and a few other important tools.
/home2/phys210/<you>/a03/
directory,
write a short bash script called "bck.sh"
that uses tar2 to make a compressed "backup" of your entire
/home2/phys210/<you>
directory tree
in a single file ~/HW.tar.gz
(note that this file should be in your $HOME directory).
Make a symbolic link to ~/HW.tar.gz
in your /home2/phys210/<you>/a03/
directory.
Here's what bck.sh should do:
First, if there is already a ~/HW.tar.gz
file,
gunzip (decompress) it to ~/HW.tar
-
then use tar to append to ~/HW.tar
any files in ~/HW/
(and its subdirectories)
that have changed since the last time
bck.sh was invoked - then gzip ~/HW.tar
back
to ~/HW.tar.gz
and you're done.
Use "man tar" to find out how to do the middle part.3 This is a valuable thing to know how to do.4
/home2/phys210/<you>/a03/
directory.
In that directory, use the convert command
supplied by ImageMagick to make files
P210logo.jpg, P210logo.png, P210logo.tif and P210logo.pdf
(plus any other graphics formats you are especially fond of).
Which file is the smallest?
Is it the one you expected?
Record (in /home2/phys210/<you>/a03/readme.txt
)
your answer and any comments.
If you want to make your own graphics (maybe a personal logo?),
try "gimp". But don't get too distracted by it!
~phys210/bin/fib.sh
to your own /home2/phys210/<you>/a03/
directory
and (using your favourite editor)
add comment lines
(any line starting with "#")
to explain what is happening at each step.
Be ridiculously thorough; it will pay off in the end.
Make sure that your copy of the file is executable
("chmod +x fib.sh") and check that
it still works like the original
despite all the comments you've added.5
So your script, which you should call fact.sh
and which should be in your /home2/phys210/<you>/a03/
directory,
should look for two arguments, and N,
so that (for example) if you invoke it with
"fact.sh 2 3" it should print out on your screen
"2 6 24 120" (not necessarily all on the same line).
This should be simple, eh?8 To keep it that way, let's forbid using
either of the first two factorials as .
Thus if you enter 1 as your first argument
you should get no response.
If you enter the wrong number of arguments, the script should print out a "USAGE: . . . " message analogous to the one in fib.sh explaining how it is supposed to be used.
Oh, and one final feature: if you enter a first argument that is not a factorial, your script should print out a polite but perhaps slightly sarcastic message informing the user that they have entered an invalid starting point.9
You may want to start with a simpler version that just prints out the first 10 or so factorials, to make sure you have that part right; then add the bells and whistles involving arguments.
~phys210/public_html/fib.php
does the same thing
as the bash shell script fib.sh,
but it does it online for anyone.
Try it out at http://www.physics.ubc.ca/~phys210/fib.php
and then convert it to make factorials
in a file called fact.php
in your own ~/public_html/p210/
directory.11