I am trying to extract a part of URL
returned in the curl
response in a bash
script. This will be used in the later stages of the script.
The curl response has this URL:
https://www.example.com/1234/text/111?x=999988
Now, I would like to extract text/111?x=999988
from it. Also, I want to store only the number 111
in a variable.
I am trying to do this with
#!/bin/bash
sample_link="https://www.example.com/1234/text/111?x=999988"
sample_extract=${sample_link##*/}
echo "$sample_extract"
But this gives me only 111?x=999988
Can anyone please let me know what am I missing and how to resolve it?
P.S: please let me know if any info is missing