Skip to main content
Formatting and shorter title
Source Link
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

How can I need to extract a part of the output fromof a cURLcurl command and useassign it as an input in the consequent cURL commandto a shell variable?

% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 277 100 174 100 103 464 274 --:--:-- --:--:-- --:--:-- 736{"result":{"progressId":"ES_7PBXiq5gg67u9Vr","percentComplete":0.0,"status":"inProg ress"},"meta":{"requestId":"**********************","httpStatus":"200 - OK"}}


% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 277 100 174 100 103 464 274
--:--:-- --:--:-- --:--:--
736{"result":{"progressId":"ES_7PBXiq5gg67u9Vr","percentComplete":0.0,"status":"inProg
ress"},"meta":{"requestId":"**********************","httpStatus":"200 -
OK"}}

I need to extract the highlighted part beginning with ES_

I tried using- | sed '"progressId":"(ES_[A-Za-z0-9]{15})' however

curl <...> | sed '"progressId"\:"(ES_[A-Za-z0-9]{15})'

however it still stores the entire output in the environment variable.

I need to extract a part of the output from a cURL command and use it as an input in the consequent cURL command

% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 277 100 174 100 103 464 274 --:--:-- --:--:-- --:--:-- 736{"result":{"progressId":"ES_7PBXiq5gg67u9Vr","percentComplete":0.0,"status":"inProg ress"},"meta":{"requestId":"**********************","httpStatus":"200 - OK"}}

I need to extract the highlighted part beginning with ES_

I tried using- | sed '"progressId":"(ES_[A-Za-z0-9]{15})' however it still stores the entire output in the environment variable

How can I extract part of the output of a curl command and assign it to a shell variable?


% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 277 100 174 100 103 464 274
--:--:-- --:--:-- --:--:--
736{"result":{"progressId":"ES_7PBXiq5gg67u9Vr","percentComplete":0.0,"status":"inProg
ress"},"meta":{"requestId":"**********************","httpStatus":"200 -
OK"}}

I need to extract the highlighted part beginning with ES_

I tried using

curl <...> | sed '"progressId"\:"(ES_[A-Za-z0-9]{15})'

however it still stores the entire output in the environment variable.

Source Link

I need to extract a part of the output from a cURL command and use it as an input in the consequent cURL command

% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 277 100 174 100 103 464 274 --:--:-- --:--:-- --:--:-- 736{"result":{"progressId":"ES_7PBXiq5gg67u9Vr","percentComplete":0.0,"status":"inProg ress"},"meta":{"requestId":"**********************","httpStatus":"200 - OK"}}

I need to extract the highlighted part beginning with ES_

I tried using- | sed '"progressId":"(ES_[A-Za-z0-9]{15})' however it still stores the entire output in the environment variable