Question:

Which Linux command is used to count the total number of lines, words, and characters contained in a file?

Show Hint

To count only specific elements (e.g., only lines, only words), you can use options with the{wc} command. For example,{wc -l file.txt} will count only the lines in the file.
Updated On: Oct 13, 2025
  • wc
  • countw
  • wcount
  • count
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

The correct answer is wc.
In Linux, thewc (word count) command is used to display the number of lines, words, and characters in a file. By default, it counts and displays the following: 1. The number of lines in the file. 2. The number of words in the file. 3. The number of characters in the file. For example, to count the lines, words, and characters in a file namedfile.txt, you would use the following command: \[ \texttt{wc file.txt} \] This will return output similar to: \[ 10 50 300 file.txt \] Where: - 10 is the number of lines. - 50 is the number of words. - 300 is the number of characters.
Explanation of Other Options:
(B) countw:
This is not a valid Linux command. There is no command namedcountw for counting lines, words, or characters in a file.
(C) wcount:
Similarly,wcount is not a valid Linux command. The correct command for counting lines, words, and characters iswc.

(D) count:
There is nocount command in Linux specifically for counting lines, words, or characters in a file.wc is the correct command to perform this task.
Summary:
- The correct command is wc, which counts the number of lines, words, and characters in a file.
- countw, wcount, and count are not valid commands for this task.
Was this answer helpful?
0
0