nerdexam
Cloudera

DS-200 · Question #15

You have a directory containing a number of comma-separated files. Each file has three columns and each filename has a .csv extension. You want to have a single tab-separated file (all .tsv) that…

The correct answer is B. Find . -name `name * .CSV' | cat | awk `BEGIN {FS = "," OFS = "\t"} {print $1, $2, $3}' > all.tsv. See the full explanation below for the reasoning.

Question

You have a directory containing a number of comma-separated files. Each file has three columns and each filename has a .csv extension. You want to have a single tab-separated file (all .tsv) that contains all the rows from all the files. Which command is guaranteed to produce the desired output if you have more than 20,000 files to process?

Options

  • AFind . -name *, CSV' ?print0 | sargs -0 cat | tr ,' `\t>t; all.tsv
  • BFind . -name name * .CSV' | cat | awk BEGIN {FS = "," OFS = "\t"} {print $1, $2, $3}' > all.tsv
  • CFind . -name *.CSV' | tr ,' `\t' | cat>; all.tsv
  • DFind . -name `*.CSV' | cat > all.tsv
  • ECat *.CSV > all.tsv

How the community answered

(63 responses)
  • A
    8% (5)
  • B
    73% (46)
  • C
    14% (9)
  • D
    2% (1)
  • E
    3% (2)

Community Discussion

No community discussion yet for this question.

Full DS-200 Practice