This is a practical exercise. You have approximately an hour. There are no restrictions placed on the resources you may use in completing this quiz, as long as you abide by the course syllabus. (In other words: you are welcome and encouraged to work with a partner, as long as the outcome is that you both understand the material.)
You are required, in this exercise, to use either vi or emacs for your authoring. Cheat sheets to help you with the commands for those editors will be provided.
Create a new script file called assignment-submission.bash.
This script should take one argument from the command line, and echo that argument back to the user. Demonstrate this to the instructor when you succeed.
To exit, the command you want to use is exit.
To make sure the directory we've been given is actually an "assignment," we'll look for a file called .osf13 in that directory.
In your example directory, create an empty file called .osf13.
In your script, add another condition, so that we make sure that we've been given a directory AND that the directory contains this file. If the special file exists, continue; if not, echo an error so that the user knows why your script exited.
We will assume the directory you are given is something you might be submitting for this course. That being the case, there should only be two kinds of files in the directory: Markdown files or LaTeX sources.
Use pushd to enter the directory.
Delete all temporary files in the directory that your text editor might create. For example, my editors often create *.swp, *~, or things I can't remember.
Delete all the mess that LaTeX leaves behind. Assume these are files ending in .log, .aux, .out, and .toc.
Use popd to exit the directory.
tar -caf filename.tar sourcedir/
The filename of your tape archive should be the same as the name of the directory.
After creating the .tar file, compress it with gzip.
gzip filename.tar
This will remove the tarfile, and leave you with a file called filename.tar.gz. Again, filename should be the same as the name of the directory.
Download this test script.
wget http://tinyurl.com/bash-test-script-py
Or, you can clone the gist:
git clone https://gist.github.com/6378127.git
Make sure it is set to be executable:
chmod 755 bash-test-script.py
Then, run it.
python bash-test-script.py
It will do the following:
As always, written work should be submitted as a Markdown document (.md) or a compressed file containing the LaTeX source of your report (.tar.gz) and a compiled PDF of the output. LaTeX submissions should be sources only, without temporary files (.aux, .log, etc.).
On Linux, you might use UberWriter or ReText for Markdown, and on Windows, MarkdownPad. Any editor works for LaTeX, although some prefer tools that are designed for the purpose.
Assignment: Command Line Hacking
Naming Convention: username-command-line-hacking
Moodle Link: http://moodle2.berea.edu/course/view.php?id=2243
The test script is included here for reference.
This website is provided under a CC BY-SA license by the
The Berea CS Department.
Fall 2013 offering of taught by Matt Jadud