IT 244: Introduction to Linux/Unix
Homework 10
Due
Sunday, November 17th at 11:59 PM
What You Need to Do
- Create the script hw10.sh
with Unix commands that will do what is described in the steps
below
- This file must be in an hw10
directory under your hw directory
Setup
-
From your home directory go to your it244
directory
cd it244
- Go to your hw directory
cd hw
- Create an hw10 directory
mkdir hw10
- Enter this new directory
cd hw10
- Create hw10.sh
nano hw10.sh
Specification
- Create the file hw10.sh inside
your hw10 directory using
nano
- Write the Unix command to perform the action specified
by each step
- Be sure to write a Step comment before the Unix
commands for each step
-
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 command 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 command 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 command 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 command 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 command 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 command 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 ~ghoffman/course_files/it244_files
to your hw10 directory
- Copy the file empty.txt
from ~ghoffman/course_files/it244_files
to your hw10 directory
- Run a command to show the permissions on the
contents of your hw10 directory
-
Write a test command 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 command 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.
Testing
Copyright © 2020 Glenn Hoffman. All rights reserved. May not be reproduced without permission.