Which command in UNIX is used to count the number of lines, words, and characters in a file?
a) wc
b) count
c) nl
d) grep
Answer:
a) wc
Explanation:
The wc (word count) command in UNIX is used to count the number of lines, words, and characters in a file. By default, it shows all three counts when you run wc filename, but you can specify options such as -l for lines, -w for words, and -c for characters.
For example, wc -l filename will return just the number of lines in the file, which is useful for quick statistics or when processing text data. You can also use wc in combination with other commands through pipes to analyze command output.
The wc command is particularly useful when dealing with large files or logs where manual counting is impractical. It provides a quick and easy way to get insights into file content size and structure.