csci 25 :: daily challenge 25
Submitting your work:

Complete this exercise on your own.

(1) Fill in all of the "Answer" boxes, (2) press "Prepare PDF", then (3) print the answer grid.

Email your PDF as an attachment to jboydt@foobt.net.

Questions:

Required reading: MUSTER 8.1 (pp. 416-447), 8.2

At the end of today's lecture, answer the following:

Your name:
  1. Briefly explain the purpose of the && operator in a BASH shell command pipeline. Then, answer YES or NO for each of the following commands -- will the echo command execute?
    • cal && echo "HELLO"
    • call && echo "HELLO"

    Answer:
  2. Briefly explain the purpose of the || operator in a BASH shell command pipeline. Then, answer YES or NO for each of the following commands -- will the echo command execute?
    • cal || echo "HELLO"
    • call || echo "HELLO"

    Answer:
  3. What is the output of each of the following commands?
    • echo today is date
    • echo today is `date`
    • echo today is $(date)
    • echo there are `ls | wc -l` files in this directory

    Answer:
  4. Answer each of the following noclobber questions:
    • use the command set -o to list your current shell options -- is noclobber on or off?
    • write the command to turn noclobber on
    • test your noclobber setting -- what is the output of the last command in this sequence?
      • cal > testcal.txt
      • date > testcal.txt
    • re-write the command "date > testcal.txt" above so that it will overwrite testcal.txt in spite of noclobber
    • write the command to turn noclobber off

    Answer:
  5. Re-write the following commands to redirect all error output to a file named errors.txt (it is recommend that you execute these commands as written first, so you can see the difference after you re-write them).
    • call && echo "HELLO"
    • cat /var/log/wtmp

    Answer:
  6. Re-write the following command to redirect all output (stdout and stderr) to a file named output.txt.
    • ls -la /shared

    Answer:
  7. What is /dev/null and what happens if the error output of a utility is redirected to /dev/null?
    Answer:
  8. Briefly explain the meaning of the shell variable "$?". What is the output of the echo statement on each of the following?
    • cat /etc/passwd; echo $?
    • cat /var/log/messages; echo $?

    Answer:
  9. Write the commands/shell instructions to do each of the following:
    • create a variable named VEGGIE with the value "spinach"
    • create a variable named OPINION with the value "like it a lot"
    • output the following: My favorite vegetable is _____ and I _____
      (fill in the blanks with the values of the variables VEGGIE and OPINION)

    Answer:
  10. Does the following sequence of commands produce any output? Does it produce the desired output? Explain precisely what has to be done (and how to do it) to produce the desired output.
    DESIRED OUTPUT: The sky is blue and the grass is green
    1. SKYCOLOR=blue
    2. GRASSCOLOR=green
    3. bash
    4. echo The sky is $SKYCOLOR and the grass is $GRASSCOLOR

    Answer:

Total points for this daily challenge:

100 points