Skip to content

Tag: jq

Formating window values with jq

I would like to take the json output of window values from a program. The output of it currently is: But I need it to be formatted like: 3067,584 764×487. How would I go about doing this using jq or other commands? I’m not very experienced with jq and json formatting in general, so I’m not really sure where to

Bash jq with dynamic name

I’m trying to create a script to read the return code from a json from a curl command. my curl command is: The json output is: How can read the value “http_httpCode#HTTP Code” if 1650468248 is a dynamic value? Answer You could use to_entries so you can use .value to target the ‘unknown’ key: Online demo Another approach by just

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 : The answer for the cURL command is this : I only need to save as a variable the first ID the cURL command gives me,

Split/Slice large JSON using jq

Would like to SLICE a huge json file ~20GB into smaller chunk of data based on array size (10000/50000 etc).. Input: Currently running in a loop to get the desire output by incrementing x/y value, but performance is very slow and takes very 8-20 seconds for a iteration depends on size of the file to complete the split process. Currently

Json response data extraction using linux command

Below is the json response of an api endpoint, I wanted to get the id value of specific name in the below array of json response. eg: I wanted to get id value(10002) of name test3, with the help of name key. Using jq I’m able to select the name key, but I’m not to find a way to get

jq script file not getting the key/value pair

I would like to put all jq filters inside a text file and use the jq -L option to execute the filters. However, I can’t get this simple thing working. Inside my sample2.json file, I have: Inside my json2csv file, I have: When I do: The output is the whole sample.json file, like this: but I would expect the output

how to for loop a jq array result in shell script

I have a json data as below now I can use below command line to get a list containing two dict, each dict have a key “data”, value is a list, I want to print each dict with a loop in shell script My except in each loop have printed a dict, total have 2 dict But it seems like

read the first line of a text file with JQ

Trying to see how I can read the first line of a text file using jq I have a text file with a bunch of ids (newfile.txt ) id like to be able to just read the first line with jq. I tried doing this But getting an error of I’d like to be able to read line by line

How to jq to copy array inside the dictionary?

I have the following json I want to convert it to How do I do this with jq? Answer The solution is the following: In the Command line: See: There is more documentation available at: Also see the hints below jqplay at the bottom.