#!/bin/bash
: ' Read JSON Value from file
/config.json
{"foo":"bar"}
'
file='config.json'
key='foo'
value=$(cat $file | sed 's/{.*\'$key'":"*\([0-9a-zA-Z]*\)"*,*.*}/\1/')
echo "The value is " $value
The big caveat to all this; it will only work with JSON on 1 line. As soon as your break up the lines this fails to capture the data. So make your data really ugly -- NOT Pretty.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.