Unix - Filters and Commands


 If the command cat x is executed after successfully executing the command time sort  filename > x, then

A. only the time details will be displayed
B. only the sorted contents of the file filename will be displayed
C. an error message will be displayed
D. None of the above

Option: B

Explanation :
The time command uses stderr, instead of stdout to display its results. As a result of this. what is redirected to x is just the output of sort filename command and not the time details. The time details will he displayed in the screen, since screen by default is the stderr


Which of the following information is not present in an i-node


Contents of the file


Name of the file


Size of the file


Both (a) and (b)


Option: D

Explanation :


The system identifies a file by its

A. name
B. absolute path
C. Both (a) and (b)
D. Mode number

Option: D

Explanation :


 The system identifies the end of a file by the

A. EOF character
B. file size
C. i-node number
D. Both (a) and (b)

Option: B

Explanation :


 The command line argument   a.out  x  'a  b'  "c  d"

A. is acceptable
B. is acceptable if the double quotes are replaced by single quotes
C. is acceptable if the single quotes arc replaced by double quotes
D. none of the above

Option: A

Explanation :
Any command that is keyed-in will be first processed by the shell, which divides the command into tokens, taking into account the metacharacters. So. a b will be divided into two tokens a and b. But 'a b' or "a b" will pass a b as such (i.e. as one token). So. argv [2] will be 'a b' and argv[3] will be "c d". Hence the answer.

Suggest an improvement