I want to parsing JSON data using jq
(as described here ) and delete any newlines character from the resulting string.
I've already tried to use tr
but this approach remove also all the white spaces between parsed values.
My code:
IP=$(curl -s https://ipinfo.io/ip) # Get ip address
curl -s https://ipinfo.io/${IP}/geo | jq -r '.ip, .city, .country' | tr -d '\n' # parse only few values from the JSON data and remove new lines.
What i get with the code above is the following string:
XXX.XXX.XXX.XXXCity_NameCountry_Name
but i want something like this:
XXX.XXX.XXX.XXX City_Name Country_Name