All mock tests are FREE till 31 December — register to save your progress

What is the function of the following UNIX command?
wc -l a > b &

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: B. It runs the word-count program to count the number of lines in its input, file a, writing the result to file b, but does it as a background process.

Explanation

wc -l a counts the number of lines in file a, and the > b redirects that count into file b — this much is common to options (i) and (ii). The deciding factor is the trailing &: in the shell, a trailing ampersand always launches the preceding command as a background job, returning control to the shell immediately rather than waiting for it to finish in the foreground. So the command counts a's lines into b while running in the background, matching option (ii), not the "foreground" claim in option (i).

More Software Engineering questions