You are troubleshooting an authentication system. The file /var/log/auth_users.log contains one username per line, but the list has never been sorted and includes mixed-case duplicates (for example, "admin", "ADMIN", and "Admin"). You need a one-liner that will:
treat lines that differ only by case as identical
show each distinct username once, preceded by the number of times it appears
display the result from the most frequent name to the least
The pipeline that works is the one that first sorts the data case-insensitively, then lets uniq collapse adjacent duplicates while counting and ignoring case, and finally re-sorts the result numerically in reverse order so the largest counts appear first:
sort -f folds upper- and lower-case so duplicate names become adjacent.
uniq -c adds the count, and -i ignores case while comparing lines; because the data are now adjacent, every instance is tallied correctly.
sort -nr orders the output on the numeric count field from highest to lowest.
Other options fail for at least one reason:
A pipeline that uses uniq -d or uniq without -c does not show the required counts (and uniq -d omits singletons).
A pipeline that relies on sort -u or wc only reports totals or unique values, not the full list with counts.
Running uniq -ci without a preceding sort will miss separated duplicates because uniq only evaluates adjacent lines.
Thus the correct solution is the pipeline that incorporates sort -f, uniq -ci, and sort -nr in that order.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does 'sort -f' do in the pipeline?
Open an interactive chat with Bash
Why is it important to use 'uniq -ci' after sorting?
Open an interactive chat with Bash
What is the purpose of the final 'sort -nr' in the solution?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
System Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .