VMware Cloud Community
MilindMK
Contributor
Contributor

Parse Curl output

Hello Everyone,

I am using below Curl command (output of VRA programing Guide) to get list of all the request

curl --insecure -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $token" https://$vRa/catalog-service/api/consumer/requests/

I want to parse the output so I can get it in a table format and the required fields only. Please let me know how I can parse the output.

Thanks,

Milind MK.

Reply
0 Kudos
1 Reply
pwilk
Hot Shot
Hot Shot

The easiest way to do that would be to use '>' or '>>' operand:

1. '>' - input

curl https://$vRa/catalog-service/api/consumer/requests/ > /path/to/doc.csv

The above command will save the output of the curl command to doc.csv located in '/path/to' directory. The content of doc.csv file would be completely erased and overwritten with the curl command output.

2. '>>' - add input

curl https://$vRa/catalog-service/api/consumer/requests/ >>/path/to/doc.csv

The above command will save the output of the curl command to doc.csv located in '/path/to' directory. The output of the curl command would be added under the last line of the existing content of doc.csv file.

Cheers, Paul Wilk
Reply
0 Kudos