Bird
0
0

You want to extract the second column from a file data.csv where columns are separated by commas. Which command pipeline correctly does this?

hard📝 Application Q15 of 15
Linux CLI - Text Processing
You want to extract the second column from a file data.csv where columns are separated by commas. Which command pipeline correctly does this?
Agrep ',' data.csv | sed 'print $2'
Bcat data.csv | awk -F',' '{print $2}'
Csed -n '2p' data.csv
Dawk '{print $2}' data.csv
Step-by-Step Solution
Solution:
  1. Step 1: Identify the field separator and extraction tool

    Columns are comma-separated, so awk with -F',' sets comma as delimiter.
  2. Step 2: Check command correctness

    cat data.csv | awk -F',' '{print $2}' uses awk -F',' '{print $2}' to print second column correctly.
  3. Final Answer:

    cat data.csv | awk -F',' '{print $2}' -> Option B
  4. Quick Check:

    awk -F',' prints columns by field [OK]
Quick Trick: Use awk -F',' to split CSV columns [OK]
Common Mistakes:
  • Using sed to print columns incorrectly
  • Forgetting to set field separator in awk
  • Using grep which filters lines, not columns

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes