IT 244: Introduction to Linux/Unix
Homework 10
Due Sunday, April 15th 11:59 PM
All this work should be done on users3.cs.umb.edu
Deliverables
-
A shell script named hw10.sh that performs the operations listed below.
This file should be in an hw10 directory inside your
hw directory inside your it244 directory.
100 points
Requirements
- Create an hw10 directory in your hw directory
inside your it244 directory
- Go to the hw10 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
hw10.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 hw10.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
./hw10.sh > /dev/null
Steps for Script
Do not use if
statements in any of the steps below
-
On a single line, create the following variables with the values given.
- Variable a with the value 5
- Variable b with the value 3
On another single command line, create the following variables with the values given.
- Variable s1 with the value "foo"
- Variable s2 with the value "foo"
- Variable s3 with the value "bar"
Print all variables and their values to the terminal.
-
Write a test expression that returns a value indicating true or false
when testing whether a is equal to b.
Echo the results of this test to the terminal.
-
Write a test expression that returns a value indicating true or false when testing whether a
is less than b. Echo the results of this test to the terminal.
-
Write a test expression that returns a value indicating true or false when testing whether a plus
b is greater than 9. Echo the results of this test to the terminal.
-
Write a test expression that returns a value indicating true or false when testing whether s1
is equal to s2. Echo the results of this test to the terminal.
-
Write a test expression that returns a value indicating true or false when testing whether s1
is not equal to s3. Echo the results of this test to the terminal.
-
Write a test expression that returns a value indicating true or false when testing whether s1
has a length greater than 0. Echo the results of this test to the terminal.
-
Do the following
- Copy the directory dir1 from ~tsoro/course_files/it244_files
- Copy the file empty.txt from ~tsoro/course_files/it244_files
- Run a single command to show the permissions on the contents of your hw10 directory
-
Write a test expression that returns a value indicating true or false when testing whether dir1
is a directory. Echo the results of this test to the terminal.
-
Write one test expression that returns a value indicating true or false when testing whether
empty.txt is readable and is writeable. Echo the results of this test to the terminal.