Skip to content
Advertisement

How can I save in a variable a portion of my cURL GET command?

I’m currently trying to setup an automated server on DigitalOcean API, and I need to extract the ID of my server to use it later in a command.

My bash command is the following :

JavaScript

The answer for the cURL command is this :

JavaScript

I only need to save as a variable the first ID the cURL command gives me, the ideal would be that when I enter :

JavaScript

I get :

JavaScript

As you can see in my first command, I tried to grep the ID, and sed it but it doesn’t work. Does anyone have any idea ?

Thanks a lot

Advertisement

Answer

You can use jq

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement