I have a sqoop command in a shell script that returns a one column one row output like this:
Can you please help me with parsing this above output to get only the value 0? Thank you.
CodePudding user response:
According to your image:

…you're needing the forlast line, right?
Piping the the output to tail -n 2 should answer
| 0 |
---------------
and from there pipe then to head -n 1 and voila.
Another approche can be to remove dash lines with `grep -v -e '^--*$' to have
| Identifier |
| 0 |
and from there, pipe then to tail -n 1 to retrieve the last line.
Finally, pipe to cut -d ' ' -f 2 or awk '{print $2}'
A refinement, if you want, will be to do the full stuff with sed or awk only. I may post an example if you want.

