I have requirement that i need to extract string using quotes. My string as follows.
"abcd efgh" "ijkl mnop" "qrst uvwxyz"
can you help me to get the string between second double quotes(ijkl mnop
) using sed
or grep
command.
In other words if I say give me the string in first quotes I want the first string; if I say second string it should give me string between second double quotes and similarly third one also.
Best Answer
I am not sure how you want to input the string. This has the effect you want to achieve, but it might need to be modified according to how the string is entered:
Edit: So, if it is in variable (it has to be defined with quoted ") :
then:
as jasonwryan pointed out above. You said, you wanted to use sed, but it makes it unnecessary complex :
Edit2: It is actually possible to achieve completely without sed,awk,perl,.. only with bash, using its "read" builtin function like this (echos are for debugging):