Interview Q&A / Linux & Shell
Linux & Shell interview questions
Permissions, processes, pipes and the commands you are expected to know cold.
Prefer rapid revision? Practise Linux & Shell short interview answers →
- How do you count how often each line appears, sorted from most to least?
Sort the input, count duplicates with uniq -c, then sort numerically in reverse: sort file | uniq -c | sort -nr. uniq only compares adjacent lines, so the first sort is required. Add head to keep the top results.
BeginnerQuick answer1 min read