Which of the following command is used to count just the number of lines contained in a file? A. wc -l B. wc -c C. wc -w D. wc -r E. None of the above

wc -l
wc -c
wc -w
wc -r E. None of the above

The correct answer is A. wc -l.

The wc command is a utility for counting words, lines, and characters in a file. The -l option tells wc to count the number of lines in the file.

The other options are as follows:

  • -c: Count the number of characters in the file.
  • -w: Count the number of words in the file.
  • -r: Reverse the order of the lines in the file.
  • None of the above: This option is not valid.

Here is an example of how to use the wc command to count the number of lines in a file:

$ wc -l file.txt
3

This output indicates that the file file.txt has 3 lines.

Exit mobile version