I was hoping to curl
data into a shell script variable, then use cat
or awk
to operate on that variable as if it was a file.
Is this possible, or is there a workaround? Do I have to save the curl
command into a file?
Do I have to run curl
several times, for each bit of string formatting I want to do?
I am curl
ing ipinfo.io, and want to output the matching lines for "city" and "region". I know how to use awk
and sed
to format the output as desired.
Try for example, curl ipinfo.io/"8.8.8.8"
for the result for a Google DNS IP address.
I'd like to print just "Mountain View" and "California," preferably on the same line, with some common formatting, like "Mountain View, California".
curl
's output (unless you want to use it multiple times), you can directly feed it tocat
orawk
. As heemayl said please explain exactly what you want to do.awk
andsed
to format the output as desired. Try for example,curl ipinfo.io/"8.8.8.8"
for the result for a google dns ip address