Bird
0
0

Which of the following is the correct awk syntax to print the third field separated by a comma?

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

    The -F, option sets the field separator to a comma.
  2. Step 2: Correct command structure

    The correct syntax places -F, before the awk program: awk -F, '{print $3}' file.csv.
  3. Final Answer:

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

    Field separator before program [OK]
Quick Trick: Use -F before program to set separator [OK]
Common Mistakes:
MISTAKES
  • Placing -F after program
  • Using commas inside print without quotes
  • Wrong order of arguments

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes