Question 1
Choose 1
A systems administrator is writing a script to analyze the number of files in the directory /opt/application
/home/. Which of the following commands should the administrator use in conjunction with ls -l | to count the
files?
Correct answer:
D. wc -l
Explanation
The administrator wants to count the number of files listed by:
ls -l
To count lines of output (each file typically appears on one line), the correct command is:
ls -l | wc -l
What wc -l does:
wc = word count utility
-l = counts lines
Each line corresponds to one listed entry, giving the total file count.
❌ Why the Other Options Are Incorrect
❌ less
Pager used to scroll output.
Does not count anything.
❌ tail -f
Continuously monitors file updates.
Used for logs, not counting lines.
❌ tr -c
Translates or deletes characters.
Not used for counting entries.
🧠 Linux+ Exam Tip
Common pipeline pattern:
Goal Command
Count files/output lines wc -l ✅
Filter text grep
Sort output sort
Remove duplicates uniq
⚠️ Exam note:
ls -l includes a “total” line, so precise counting often uses:
ls -1 | wc -l
But for this question, wc -l is the intended answer.
The administrator wants to count the number of files listed by:
ls -l
To count lines of output (each file typically appears on one line), the correct command is:
ls -l | wc -l
What wc -l does:
wc = word count utility
-l = counts lines
Each line corresponds to one listed entry, giving the total file count.
❌ Why the Other Options Are Incorrect
❌ less
Pager used to scroll output.
Does not count anything.
❌ tail -f
Continuously monitors file updates.
Used for logs, not counting lines.
❌ tr -c
Translates or deletes characters.
Not used for counting entries.
🧠 Linux+ Exam Tip
Common pipeline pattern:
Goal Command
Count files/output lines wc -l ✅
Filter text grep
Sort output sort
Remove duplicates uniq
⚠️ Exam note:
ls -l includes a “total” line, so precise counting often uses:
ls -1 | wc -l
But for this question, wc -l is the intended answer.