Bird
0
0

Which of the following is the correct syntax to print the third field using awk with a comma as the field separator?

easy📝 Syntax Q12 of 15
Bash Scripting - Text Processing in Scripts
Which of the following is the correct syntax to print the third field using awk with a comma as the field separator?
Aawk -F ',' '{print $3}' file.csv
Bawk '{print $3 -F ','}' file.csv
Cawk '{print $3, -F ","}' file.csv
Dawk -F ';' '{print $3}' file.csv
Step-by-Step Solution
Solution:
  1. Step 1: Identify field separator option

    The -F option sets the field separator. For comma-separated files, use -F ','.
  2. Step 2: Check print syntax

    The correct print syntax is '{print $3}' to print the third field.
  3. Final Answer:

    awk -F ',' '{print $3}' file.csv -> Option A
  4. Quick Check:

    Use -F ',' before script block [OK]
Quick Trick: Use -F 'separator' before the awk script block [OK]
Common Mistakes:
MISTAKES
  • Placing -F inside the print statement
  • Using wrong separator like semicolon for CSV
  • Misplacing quotes around separator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes