Given a JSON file, arguments.json:
{"dagger": true, "version": false, "nether_strike": true,
"greater_bash": "5", "FILE": "ancientscroll.txt",
"empower_haste": "1", "help": false}
When calling reading the variables as such:
#!/bin/bash dagger=$(cat arguments.json | jq '.["dagger"]') greater_bash =$(cat arguments.json | jq '.["greater_bash"]') echo $dagger echo $greater_bash
[out]:
true "5"
The variable contains the quotation marks "".
How to remove the quotes when reading a variable in jq?
I could use sed to strip the quotes as such:
greater_bash =$(cat arguments.json | jq '.["greater_bash"]' | sed -e 's/^"//' -e 's/"$//') echo $greater_bash
[out]:
5
Related Posts:
- Select objects based on value of variable in object using jq
- How to grep for case insensitive string in a file?
- How to install JQ on Mac on the command line?
- “sed” command in bash
- How to remove double-quotes in jq output for parsing json files in bash?
- How to sort a json file by keys and values of those keys in jq
- Can comments be used in JSON?
- Can comments be used in JSON?
- How do I pause my shell script for a second before continuing?
- Angular: ‘Cannot find a differ supporting object ‘[object Object]’ of type ‘object’. NgFor only supports binding to Iterables such as Arrays’
- How do I split a string on a delimiter in Bash?
- Grabbing the current viewer count for youtube live streaming
- In the shell, what does ” 2>&1 ” mean?
- Use of PUT vs PATCH methods in REST API real life scenarios
- Extract substring in Bash
- What is the easiest way to convert an Excel spreadsheet with tabular data to JSON? [closed]
- Can comments be used in JSON?
- Ubuntu says “bash: ./program Permission denied” [closed]
- Yahoo Finance All Currencies quote API Documentation
- In the shell, what does ” 2>&1 ” mean?
- How do I use a regex in a shell script?
- How to concatenate string variables in Bash
- -bash: syntax error near unexpected token `)’
- An example of how to use getopts in bash
- Difference between wait and sleep
- Multi-line string with extra space (preserved indentation)
- How to delete from a text file, all lines that contain a specific string?
- uncaught syntaxerror unexpected token U JSON
- Multi-line string with extra space (preserved indentation)
- What is the difference between YAML and JSON?
- ‘\r’: command not found – .bashrc / .bash_profile [duplicate]
- Representing null in JSON
- Loop through an array of strings in Bash?
- ‘\r’: command not found – .bashrc / .bash_profile [duplicate]
- How can I check if a directory exists in a Bash shell script?
- How do I iterate over a range of numbers defined by variables in Bash?
- pretty-print JSON using JavaScript
- How do I iterate over a range of numbers defined by variables in Bash?
- Fastest JSON reader/writer for C++
- Representing null in JSON
- YAML equivalent of array of objects in JSON
- “unary operator expected” error in Bash if condition
- Are multi-line strings allowed in JSON?
- Parsing a JSON string in Ruby
- Are multi-line strings allowed in JSON?
- What does “-ne” mean in bash?
- How can I declare and use Boolean variables in a shell script?
- How to reload .bashrc settings without logging out and back in again?
- How can I declare and use Boolean variables in a shell script?
- How to reload .bash_profile from the command line?
- What is the purpose of “&&” in a shell command?
- How to generate random number in Bash?
- Replace one substring for another string in shell script
- Parsing JSON with Unix tools
- How to check if a variable is set in Bash?
- Remove properties from objects (JavaScript)
- “[ ]” vs. “[[ ]]” in Bash shell
- How do I split a string on a delimiter in Bash?
- Pseudo-terminal will not be allocated because stdin is not a terminal
- How can I compare numbers in Bash?
- Python/Json:Expecting property name enclosed in double quotes
- What is a list in Bash?
- Open and write data to text file using Bash?
- How can I count all the lines of code in a directory recursively?
- How can I kill a process by name instead of PID, on Linux?
- Given two directory trees, how can I find out which files differ by content?
- Which characters need to be escaped when using Bash?
- Why do i need `typings.json` file in an Angular 2 project?
- Shell: How to call one shell script from another shell script?
- Basic example of using .ajax() with JSONP?
- Pseudo-terminal will not be allocated because stdin is not a terminal
- find: missing argument to -exec
- How do I set a variable to the output of a command in Bash?
- ./configure : /bin/sh^M : bad interpreter
- Is there a TRY CATCH command in Bash
- Best way to save data in Unity game
- How to check if an environment variable exists and get its value?
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- Javascript Object push() function
- How to convert a string to lower case in Bash?
- Is there a “goto” statement in bash?
- Run a string as a command within a Bash script
- Create a new file in git bash
- How do you represent a JSON array of strings?
- RE error: illegal byte sequence on Mac OS X
- Using Wikipedia API on custom wikis like Bulbapedia
- How to specify the private SSH-key to use when executing shell command on Git?
- Sorting data based on second column of a file
- Writing a simple shell in C using fork/execvp
- Speed up rsync with Simultaneous/Concurrent File Transfers?
- sed command with -i option failing on Mac, but works on Linux
- Multi-dimensional arrays in Bash
- Using SED with wildcard
- Variable interpolation in the shell
- chmod: changing permissions of ‘my_script.sh’: Operation not permitted
- What’s the meaning of the parameter -e for bash shell command line?
- How to import a JSON file in ECMAScript 6?
- zip error – Nothing to do
- UnicodeDecodeError: ‘utf8’ codec can’t decode byte 0x80 in position 3131: invalid start byte
- How to sort an array in Bash