183. Which one of the following lines of unix commands can tell you the number of lines in a file?
A. pc – f
B. Is – a
C. df – h
D. wc – I
Correct Usage: wc -l
The command:
wc -l filename.txt
Explanation:
-
wcstands for “word count”. -
The
-loption counts the number of lines in the specified file. -
It returns a number representing total lines, followed by the file name.
Example:
$ wc -l myfile.txt
24 myfile.txt
Why Other Options Are Incorrect:
-
A. pc – f: Not a valid Unix command.
-
B. ls –a: Lists all files including hidden ones in a directory; does not count lines.
-
C. df –h: Displays disk space usage in a human-readable format; unrelated to line counts.
-
D. wc –I: Incorrect option;
-Iis not a standard flag forwc.
Note: The option should be lowercase
-l, not an uppercase “i” or “L”.
Conclusion
To count the number of lines in a file on Unix/Linux systems, use wc -l. It’s simple, efficient, and widely used by system admins and developers alike.
Correct Answer: D. wc -l (not wc -I as in the question, which appears to be a typo)
Let me know if you’d like a cheat sheet on commonly used Unix commands.
7 Comments
Khushi yadav
April 17, 2025Done
Yashika Rajoriya
April 17, 2025✅
Suman bhakar
April 17, 2025Okay sir
Monika Sharma
April 22, 2025Done ✅
Prami Masih
April 22, 2025Okay
SEETA CHOUDHARY
April 24, 2025Done ✅
yogesh sharma
April 29, 2025😰😰