Command Line Assignment 5A

(16 points)

Due In class at start of class

This is a work sheet assignment, all work is to be done on this page. This means this page is due in class at start of class on the due date.

Assume you have two sets of commands. The first set, s1, s2, s3, s4, s5, s6, and s7 will run successfully and issue the return code 0 (success). The other set, f1, f2, f3, f4, f5, f6, and f7 fail on execution and issue the return codes 1, 2, 3, 4, 5, 6, and 7, repectively.

For each command sequence listed below, circle all commands that run and enter the final return code in the space following each command line sequence. Remember the first command always runs, so circle it.

You can make this part of the assignment easier if you actually create the commands.

For each of the success commands s1, s2, s3, s4, s5, s6, and s7, copy the following bourne shell script. If you want, you can create a single file and hard link the 6 additional names to the original file.

For each of the fail commands f1, f2, f3, f4, f5, f6, and f7, copy the following bourne shell script. If you want, you can create a single file and hard link the 6 additional names to the original file.

For each problem listed below, enter the command sequence as it is shown on the left hand side of the page.

Circle each command that executes (runs). Remember, the first command will always run. Also, a command can run and still return a failure code. All commands that run, will print their names out.

Enter the final return code for each command line sequence in the blank at the right. If you use the shell scripts above to actually test your guesses, you can find the return code of the last executed command by typing echo $status at the prompt immediately after running the stated command sequence.


Command sequences to analyze - remember to run echo $status after each sequence.

a) s1 || s2 || s3                                          r.c. = _______

b) s1 && s2 && s3 r.c. = _______

c) f1 || f2 || f3 r.c. = _______

d) f1 && f2 && f3 r.c. = _______

e) s1 || s2 && s3 r.c. = _______

f) f1 || f2 && f3 r.c. = _______

g) s1 && s2 || s3 r.c. = _______

h) f1 && f2 || f3 r.c. = _______

i) s1 && s2 || s3 || s4 && s5 || s6 r.c. = _______

j) f1 && f2 || f3 || f4 && f5 || f6 r.c. = _______

k) f1 && f2 && f3 && f4 && f5 || f6 && f7 r.c. = _______

l) f1 || f2 || s3 || s4 || f5 && f6 || f7 r.c. = _______

m) f1 || f2 || s3 && s4 || f5 && f6 || f7 r.c. = _______

n) ( f1 || f2 || s3 || f4 ) && ( s5 || f6 ) && ( f7 || s7 ) r.c. = ____

o) ( s1 && f2 && s3 && f4 ) || ( s5 && s6 ) || ( f7 && s7 ) r.c. = ____

p) (( f1 || s1 && s2 ) || ( f2 && f3 || f4 )) && ( s3 || f5 ) r.c. = ____