I am trying to script the extraction of a value from a curl call return data, but I am failing to get the exact output.
The command I use is like this:
The second grep is because the searchfor term appears on two lines but I want the one that also contains 'source:'
Now I get a long string and I want to extract the stuff following source: and enclosed between two " so there is a line to process looking like this:And I want to extract what follows {source: and is between the two double quotes
So:
- use grep at two levels to get the single matching line
- then search for source: on that line
- then extract what follows this and enclosed by double quotes.
How can this be done in a bash script file using grep, sed, awk or whatever?
The command I use is like this:
Code:
curl -s https://somewhere.com/token/ | grep searchfor | grep 'source:'
Now I get a long string and I want to extract the stuff following source: and enclosed between two " so there is a line to process looking like this:
Code:
a lot of text with many words "some of them enclosed like this" and < text> ({source: "someurl:8443/live/smil:fx1.smil/index8.html", then even more text
So:
- use grep at two levels to get the single matching line
- then search for source: on that line
- then extract what follows this and enclosed by double quotes.
How can this be done in a bash script file using grep, sed, awk or whatever?
Statistics: Posted by Bosse_B — Tue Feb 06, 2024 12:25 pm — Replies 1 — Views 24