Bird
0
0

Given a file data.txt with the following content:

medium📝 Command Output Q13 of 15
Linux CLI - Text Processing
Given a file data.txt with the following content:
apple 10 red
banana 5 yellow
cherry 20 red

What is the output of awk '{print $1, $3}' data.txt?
Aapple red banana yellow cherry red
Bapple banana cherry
C10 red 5 yellow 20 red
Dapple 10 banana 5 cherry 20
Step-by-Step Solution
Solution:
  1. Step 1: Identify fields in each line

    Each line has three fields: $1=fruit, $2=number, $3=color.
  2. Step 2: Understand the print command

    awk '{print $1, $3}' prints the first and third fields separated by space.
  3. Final Answer:

    apple red banana yellow cherry red -> Option A
  4. Quick Check:

    Print first and third fields [OK]
Quick Trick: Match $1, $2, $3 to columns in order [OK]
Common Mistakes:
  • Mixing up field numbers
  • Printing wrong fields or all fields
  • Ignoring spaces between printed fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes