jq is amazing for manipulating json on the commandline, but the developers have some weird ideas about how to handle shell redirections. This command works around them. Further reading: https://github.com/stedolan/jq/issues/1110
Returns the current price of a troy ounce of gold, in USD. Requires the "jq" JSON parser. Show Sample Output
It is the same but more faster real 0m0,007s user 0m0,011s sys 0m0,000s with my solution real 0m0,038s user 0m0,044s sys 0m0,000s with your solution :) Show Sample Output
Use the AWS CLI tools to generate a list instances, then pipe them to JQ to show only their launch time and instance id. Finally use sort to bring them out in runtime order. Find all those instances you launched months ago and have forgotten about. Show Sample Output
You can do the filtering natively in the aws cli, without using jq (although jq is awesome!) Show Sample Output
Uses the python-based AWS CLI (https://aws.amazon.com/cli/) and the JSON query tool, JQ (https://stedolan.github.io/jq/)
With this command you can convert a tab separate file (TSV) into a JSON file with jq. For example, this input.tsv i-0b9adca882e5e6326 172.16.0.188 i-088dd69e5c3624888 172.16.0.102 i-0e70eac180537d4aa 172.16.0.85 will produce the showed output. Show Sample Output
Use lsbk (list block) and jq (to manipulate a JSON on the command line) to display partition information: Show Sample Output
Frustrated with the manual domain migration process AWS has, I unsuccessfully tried to install cli53, route53-transfer. I instead wrote this oneliner to ease the export (which is not supported via the AWS console ATM). The output can be easily pasted into the "Import Hosted Zone" dialog in Route53. SOA/NS records are excluded since they cannot be automatically imported. Show Sample Output
Sometimes things break. You can find the most recent errors using a combination of journalctl, along with the classic tools sort and uniq Show Sample Output
Uses the python-based AWS CLI (https://aws.amazon.com/cli/) and the JSON query tool, JQ (https://stedolan.github.io/jq/)
If you have a load of logstash events in a redis queue (here named "logstash"), here's a fast way to examine the type and message of the event.
Returns the global weighted BTC rate in EUR. Requires the "jq" JSON parser. Show Sample Output
Grabs the first JSON file in the directory, reads its keys, prints TSV, then prints all the json files' values as TSV. Nested objects appear as json. Unhappy times if your json has literal tabs in it. Show Sample Output
Looking up the id of a CF domain can be painful. Not anymore with this tip. Show Sample Output
# Usage: ftagmarks TAG BOOKMARKS.JSON
ftagmarks Bash ~/.mozilla/firefox/*.default/bookmarkbackups/bookmarks-*.json
Tag can be partial matching, e.g. input 'Bas' or 'ash' will match 'Bash' tag.
# Exact tag matching:
ftagmark(){ jq -r --arg t "$1" '.children[] as $i|if $i.root == "tagsFolder" then ([$i.children[] as $j|{title: ($j.title), urls: [$j.children[].uri]}]) else empty end|.[] as $k|if $k.title == $t then $k.urls else empty end|.[]?' "$2"; }
Usage: ftagmark TAG BOOKMARKS.JSON
# List all tags:
ftagmarkl(){ jq -r '.children[] as $i | if $i.root == "tagsFolder" then $i.children[].title else empty end' "$1"; }
Usage: ftagmarkl BOOKMARKS.JSON
# Requires: `jq` - must have CLI JSON processor
http://stedolan.github.io/jq
Show Sample Output
Compactly display a bitcoin-cli fee estimate in satoshis/Byte, sat/B, date time stamp. Change the 6 to the desired number of confirmations.
Display in btc/KB unit of measure:
printf %g "$(bccli estimatesmartfee 6 "ECONOMICAL" | jq .feerate)";printf " btc/KB estimated feerate for 6 confirmations\nMultiply by 100,000 to get sat/B\n";
Two settings for estimate mode are "ECONOMICAL". "CONSERVATIVE" is the same as "UNSET"
# jq is a json filter.
sudo apt-get install jq
Show Sample Output
This allows you to get all instance profiles (roles) for a given set of tags. Lists it in CSV Show Sample Output
Hit an API with curl returning a random quote, then parse the result with jq. Show Sample Output
The only pre-requisite is jq (and curl, obviously). The other version used grep, but jq is much more suited to JSON parsing than that. Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: