How to get the second column from command output?

My command’s output is something like:

1540 "A B"
   6 "C"
 119 "D"

The first column is always a number, followed by a space, then a double-quoted string.

My purpose is to get the second column only, like:

"A B"
"C"
"D"

I intended to use <some_command> | awk '{print $2}' to accomplish this. But the question is, some values in the second column contain space(s), which happens to be the default delimiter for awk to separate the fields. Therefore, the output is messed up:

"A
"C"
"D"

How do I get the second column’s value (with paired quotes) cleanly?

8 Answers
8

Leave a Comment