https://github.com/coderofsalvation/bashdownjson
portable/easy way of generating of json feeds using commandline (piping) using 100% bash and bashdown templates
https://github.com/coderofsalvation/bashdownjson
Last synced: about 1 year ago
JSON representation
portable/easy way of generating of json feeds using commandline (piping) using 100% bash and bashdown templates
- Host: GitHub
- URL: https://github.com/coderofsalvation/bashdownjson
- Owner: coderofsalvation
- License: agpl-3.0
- Created: 2014-01-05T01:17:05.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2020-05-28T18:17:26.000Z (about 6 years ago)
- Last Synced: 2025-02-12T06:22:59.120Z (over 1 year ago)
- Language: Shell
- Size: 14.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
bashdownjson
===========
portable/easy way of generating of jsonfeeds using commandline (piping) using 100% bash and bashdown templates
Usage
=====
$ ./bashdownjson
Usage:
add: echo 'foo bar' | bashdownjson add your.json
echo '{"foo":"bar"}' | bashdownjson add your.json
reset: bashdownjson reset your.json
print: bashdownjson generate your.json [maxitems]
One doesnt have to be an Einstein to figure this makes it perfect for crontab, fifo/pipe's and *any* kind of applications..since its all bash :)
Example
=======
put this into your crontab to generate the feed hourly (feel free to modify) with always the latest 10 items:
@hourly /path/to/bashdownjson print errors.json 10 > /var/www/foo/errors.json
now with tail(f) you can easily monitor some (log)files etc:
tailf /some/application/log.txt | grep "ERROR" | ./bashdownjson add errors.json
Example output
==============
The 'add' command in the Usage-example above, would eventually generate this output when './bashdownjson print your.json' would be called:
{
"system": "Linux lemon 2.6.32-042stab076.5 #1 SMP Mon Mar 18 20:41:34 MSK 2013 x86_64 GNU/Linux",
"date": "Sun, 05 Jan 2014 16:56:49 +0100",
"items": [
{
"id" : "1388937285",
"date": "Sun, 05 Jan 2014 16:54:45 +0100",
"data": {"text":"foo bar"}
}
,
{
"id" : "1388937305",
"date": "Sun, 05 Jan 2014 16:55:05 +0100",
"data": {"flop":"flap"}
}
]
}
This is just a simple example but you'll get the point I guess :)
Requirements
============
* written in +/- 50 lines of bash, the ultimate swiss army knife
Credits
=======
* [bash(down) template 'engine'](https://github.com/coderofsalvation/bashdown)