I'm trying to use cut -f to get desired part of the following:
""
""
""HTTP/1.1""200""OK""
In order to get HTTP/1.1, I'll need to do:
cut -f 3,3 -d '"'
Result will be:
empty
empty
HTTP/1.1
So first two lines will be empty, (I use "empty" to indicate that)
But I would need to keep the empty string:
""
""
HTTP/1.1
I guess I need to introduce if-else, that if original line is empty then stop cut, just keep ""? But how can I do this using one-line bash?
Thanks
======= A followup question: How to change
,,,
to
,"","",""
s/^$/\"\"/g does not work here.
You can pipe the result of your cut command to:
sed s/^$/\"\"/g
It will replace the empty lines with "".
That is:
cut -f 3,3 -d '"' | sed s/^$/\"\"/g
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With