Bird
0
0

The command sort | uniq -c gives an error: "uniq: missing operand after '-c'". What is the error?

medium📝 Debug Q7 of 15
Bash Scripting - Text Processing in Scripts
The command sort | uniq -c gives an error: "uniq: missing operand after '-c'". What is the error?
Auniq -c requires a filename argument
Buniq -c must be used without a pipe
CThe pipe is missing input before sort
Dsort command is missing input file
Step-by-Step Solution
Solution:
  1. Step 1: Check the pipeline input

    Both sort and uniq expect input; if no input is piped, uniq -c errors.
  2. Step 2: Identify missing input before sort

    If no file or input is given to sort, it waits or fails, causing uniq error.
  3. Final Answer:

    The pipe is missing input before sort -> Option C
  4. Quick Check:

    Commands need input; missing input causes uniq error [OK]
Quick Trick: Ensure input is piped or file given before sort [OK]
Common Mistakes:
MISTAKES
  • Assuming uniq -c needs filename
  • Not providing input to sort
  • Misunderstanding pipe usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes