Quantcast
Browsing all 522 articles
Browse latest View live

How I can compare these two .json files correctly using jq in a bash script...

I have a bash script that is set up below which is attempting to compare the remote s3 version of a file with the local version. Currently, the if conditions I try never actually work. The latest...

View Article


stringify bash array to json string

I'm new to bash and I have a bash script with a variable that is an array called 'output'I'd like to convert the bash array to a JSON string. for example:original array:output = ['one', 'two']desired...

View Article


Parsing a nested JSON record present in an array of objects

I want to get down to the values in Wind / Direction.One example (of many) I've tried, [I want to use jq in a bash script]:cat accuweather_raw | jq ".Wind[].Direction[] | [.Localized]"Most times I get...

View Article

Update array element of a JSON array with jq

I have a JSON object and would like to update for example the array element "role[test09]" to "role[hello]", I don't have the index number. I have tried a few things but somehow can't figure it out.How...

View Article

Shell script for copying environment variables into config.json? [duplicate]

I'm tearing my hair out a bit at this. I'm trying to write a shell script which indexes through all environment variables, and then overrides variables in a config.json file.I have a demo angular app...

View Article


Export environment variables to JSON in Bash

The environment variables can be printed by using export or printenv in bash, but how can we convert the output into JSON format and then store them in a variable.

View Article

Parsing JSON with Unix tools

I'm trying to parse JSON returned from a curl request, like so:curl 'http://twitter.com/users/username.json' | sed -e 's/[{}]/''/g' | awk -v k="text"'{n=split($0,a,","); for (i=1; i<=n; i++) print...

View Article

Why my string comparison isn't working in bash?

I've a script that does something like this:set -xmyJson="echo '{\"data\":\"true\"}'"commandOutput=$(eval $myJson | jq '.data')echo $commandOutputwhile :do if [[ $commandOutput == "true" ]] then break...

View Article


jq : Generate UUID in field

I have a requirement to tag records uniquely with UUIDs (for a correlation id). I cant see a direct way to do this via the options, is such a thing possible? If not, is there some kind of workaround...

View Article


How to get brew list as JSON output

I am running brew list --versions to get this list: user@mac ~ [1]> brew list --versions fish 3.7.0 ncurses 6.4 pcre2 10.43 syncthing 1.27.4 appcleaner 3.6.8 teamviewer 15.51.6How can I put the...

View Article

Run jq command in git-bash

jq command not found after adding jq executableinstalling jq on git bashMy usecase is more similar with above shared references. I tried to execute a hook that needs to parse a json file. When hook...

View Article

Modify json with string in it

I have a json file like this:{"arrays": ["a_string", {"name": "foo","properties": [ {"type": "some_type1","url": "https://example.com","checksum":...

View Article

Modify object in a JSON array that also contains strings

I have a JSON file like this:{"header": "headername","arrays": ["a_string", {"name": "foo","properties": [ {"type": "some_type1","url": "https://example.com","checksum":...

View Article


read raw input lines and output single array

I have a directory with files in it. I would like to create an array from that list of files. I thought it would be pretty easy, like:ls mydir | jq -R '[.]'["file1"]["file2"]["file3"]The only thing I...

View Article

Is there a way of extracting portion of a key value between delimiters?

Here is my JSON. Its in a file called file1.txt{"foo": [ {"bar": {"second": {"key1": "some/path/to/delimiter1_FIRST_IMPORTANT_VALUE_delimter2","key2": "OK_as_it_is","key3": "Just to show there is more...

View Article


JQ JSON - Values to Array [closed]

A confusion of getting to the bottom of a jq parse.I'm learning, apreciate your help.Two arrays here, both with same type ouput result, just integer values (spaced), same for string values.Ex: 1 2 3 4...

View Article

Run an external command within jq to manipulate each values of a particular key

I have a json like[ {"url": "https://drive.google.com/file/d/1tO-qVknlH0PLK9CblQsyd568ZiptdKff/view?usp=share_link","title": "&#8211; Flexibility" }, {"url":...

View Article


JQ Parse not returning indexed array just numbers

I have a multi-nested weather dump (Accuweather):I am trying to get an indexed response/array ([0,...]) to sort - json and/or bash of the values. But my queries are only getting numbers-space...

View Article

JQ delete property based other property value

I'm trying to write a JQ filter allowing me to selectively filter object properties based on other of it's values.For example, given following input{"object1": {"Type": "Type1","Properties":...

View Article

parse error while passing helm show chart to jq

Hi I am getting a parse error when i perform the following commandhelm show chart https://artifactory.vvr.com/artifactory/helm-release-local/jaeger/jaeger-assembly/jaeger-assembly-1.0.0.tgz -n test |...

View Article
Browsing all 522 articles
Browse latest View live