6. [15 marks] What is the output (on stdout) from the following commands? If you can't tell from the information given, state what additional information you would need.

General solutions note: If you don't understand the supplied answer, now that you're no longer in the exam situation, please actually try the command, and experiment from there.

a) test x = x

Answer: no output to stdout

b) expr 2 + 3 | wc -l

Answer: 1

c) echo hi | wc -c

Answer: 3

d) (echo hi; echo bye) | sort

Answer:
bye
hi

e) echo hi; echo bye | wc -l

Answer:
hi
1

f) expr 2 * 3

Answer: It depends upon what files are in the current directory, because '*' is substituted accordingly.
(E.g. if there is only one file and it is named '+', then this command line will expand to "expr 2 + 3" and yield the output "5".)

Grading:
Out of: 3, 2, 2, 2, 3, 3.
For part (f), just saying that you think the author meant expr 2 \* 3 was worth one out of 3. The question was what does happen, and this is a much harder question.


[press 'back' in your web browser to return to where you were in the exam]