Embedded Commands   «Prev  Next»

Unix Embedded Command Syntax - Quiz

Each question is worth one point. Select the best answer or answers for each question.
 
1. How does embedded command execution differ from redirection?
Please select the best answer.
  A. Embedded commands copy output to the text of a command. Redirection copies command output to a file.
  B. They are interchangeable techniques, doing essentially the same thing.
  C. Embedded commands copy output to a file. Redirection copies command output to another command.
  D. Embedded commands cannot be used on the command line, but redirection can.

2. What is the difference between the following two commands?
tar –cvf /tmp/cfiles.tar *.c

tar –cvf /tmp/cfiles.tar `find . –name "*.c" –print`

Please select the best answer.
  A. The first command uses embedded command execution, but the second does not.
  B. The second command uses embedded command execution, but the first does not.
  C. The first command will archive files from subdirectories, but the second will not.
  D. The second command will archive files from subdirectories, but the first will not.

3. You are writing a for loop in your shell. You want the loop to copy each line of file1 to the variable currentline, one line per loop iteration. What change might you make to the following code to accomplish this?
for currentline in `cat file1`
do
  # this part deliberately left blank
done

Please select the best answer.
  A. Add double quotes around your embedded command.
  B. Don’t change anything, leave the loop the way it is.
  C. Add single quotes around your embedded command.
  D. Set the IFS variable to a carriage return before running the for loop.

4. Which of the following commands contain useful applications of embedded command execution?
Please select all the correct answers.
  A. weekday=`date +%A`
  B. echo `ls`
  C. ls –l > files.`date +%A`
  D. `pwd`
  E. echo “The current directory is `pwd`”

5. If you run the following command and receive the output shown, which answer is true?
$ `date`

ksh: Wed:  not found
Please select the best answer.
  A. The shell cannot find the date command.
  B. The shell cannot find the ksh command.
  C. Today is Wednesday.
  D. Today is not Wednesday.