IT 244: Introduction to Linux/Unix
Homework 6
Due Sunday, March 04th at 11:59 PM
All this work should be done on users3.cs.umb.edu
Deliverables
-
A shell script named hw6.sh that performs the operations listed below.
This file should be in an hw6 directory inside your
hw directory inside your it244 directory.
100 points
Requirements
- Create an hw6 directory in your hw directory
inside your it244 directory
- Go to the hw6 directory and run Unix commands that will execute the steps below
- When you have a command line that does what the step asks you to do, paste it into
hw6.sh using
nano
or any other text editor
- When you have completed all the steps, create an
echo
statement before the commands
for each step, that will print the step number to the terminal
Testing
- The script hw6.sh must have the format specified in
this document
- Scripts that do not follow the rules specified in the document mentioned above will
will have points deducted from their score
- Be sure to test your script and correct any errors you find
- You will lose 5 points for each error that occurs when running your script
- To run your script and see only the error messages run the following command
bash hw6.sh > /dev/null
Steps for Script
-
Run a command which will show how much free space exists on the file system.
You must use an option which will show the space in a way that
is easy for human beings, like us, to understand.
-
Run
cat
with an option that prints to the terminal a help message for this command.
-
Print to the terminal the value of a variable that shows where the shell will look
for an executable file to match the command you typed at the terminal.
-
In ~tsoro/course_files/it244_files you will find a file named
hello.sh.
Stay in your hw6
directory and run hello.sh using an absolute pathname.
Run this script without using bash
, or any other shell, followed by the name
of file.
-
Copy hello.sh to your hw6 directory.
List the contents of your hw6 directory to make sure file was copied.
Run this copy hello.sh using a relative pathname.
You must do this while staying in your
hw6 directory and without using bash
or any other shell.
-
In the directory /home/tsoro/course_files/it244_files,
you will find a red_sox.txt file.
Stay in your hw6 directory.
Using redirection, create the file red_sox_wins.txt.
This file must contain all the entries in red_sox.txt
where the Red Sox won.
Do not copy the red_sox.txt
file to your hw6 but use a relative or absolute path to this file in
the /home/tsoro/course_files/it244_files directory.
Print the contents of this file to the terminal.
-
List the contents of your current directory.
Print to the terminal the exit status of the command you just ran.
Try to list the contents of a directory that does not exists like xxxxxxx.
Print to the terminal the exit status of the command you just ran.
-
Stay in your hw6 directory.
Using ls
and output redirection, create a file named dir_listing.txt
that contains the list of files in your home directory.
Print this file to the terminal.
-
Stay in your hw6 directory.
Using redirection, create a file named list.txt containing a list
of all the users currently logged in.
Print this file to the terminal.
-
Stay in your hw6 directory.
Using redirection, add a listing of the contents of your hw6 directory to
dir_listing.txt.
That is, I want you to keep the original contents of dir_listing.txt intact
while running ls
of your current directory to it.
Print this file to the terminal.