When executing docker-machine inspect command, instead of the expected highlighted version of JSON piped into jq:
I'm seeing the following plain output (in cmd or ConEmu):
Not sure what needs to be done to enable proper json highlighting.
This happens on Windows 10 machine on which jq ver. 1.5 was installed via Chocolatey:
Apparently, this is an idiosyncrasy of jq Windows implementation, forcing the color output with -C option, as hinted by several commenters above, resolved the issue for me:
Related
How can I find the latest version of Google Chrome from a shell script (e.g. bash) on Linux ?
For ChromeDriver, I can do this:
curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE
Can I do something similar for Chrome?
Background to question
T
his needs to be done in a pipeline and there is no local install of Chrome, no tools to inspect packages (rpm, deb, and the like). The reason I want this is so that I can download the latest version as a numbered package. I could do this
wget -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
but that results in a file called google-chrome-stable_current_amd64.deb rather than one that is version stamped such as google-chrome-stable_73.0.3683.103-1_amd64.deb.
If I know the version in advance, I can get a version-stamped file using this:
GOOGLE_CHROME_VERSION=73.0.3683.103-1
wget http://dl.google.com/linux/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${GOOGLE_CHROME_VERSION}_amd64.deb
So what I'm really looking for is either generic URL that always returns the latest version-stamped file or a way to set GOOGLE_CHROME_VERSION in the above.
If you are using Ubuntu Desktop like mine 16.04, here is the command
google-chrome --version
ref. https://askubuntu.com/a/505532/22308
I reduce the problem to its lowest terms.
Under linux a git command like this:
git log --pretty=format:{"commit":"%H"}
gives me a valid json element, so something like:
{"commit":"20cafdecc9898113ac6215ae70cd7622dc2cae3b"}
under windows I obtain a not-valid json element, because in some way windows seems to remove the double-quotes elements and I obtain:
{commit:20cafdecc9898113ac6215ae70cd7622dc2cae3b}
Do you know why, or how can I fix it making it work under both os?
Thank you!
I assume that your shell on Linux is NOT a bash shell because my bash shell on Linux gives me the same output as on Windows - without double-quotes.
The doubles-quotes are special characters for most shells - so you have to protect them either by "escaping" or by "quoting".
git log --pretty=format:{\"commit\":\"%H\"}
git log --pretty='format:{"commit":"%H"}'
This works for bash on Linux and bash on Windows. I have not tested it with cmd on Windows.
I've found out about vim-rest-console, but after installed and run a test, I noticed the JSON it outputs is only in one line, without any indentation. This is horrible and I'd like to know if there is a way to solve this. I am using NeoVim on Xubuntu 16.04 LTS.
To fix the json indentation in Vim, put the following command to your .vimrc
nmap =j :%!python -m json.tool<CR>
and launch it via the =j command (or remap to different shortcut).
I've used python -m json.tool to pretty print JSON and check for errors for years. It is nice because it works on just about any system with python installed. How can I take out unnecessary whitespace that JSON ignores (i.e. not in string values) without installing on mac/linux/bsd/unix systems without installing anything special? Answers that work on recent baseline mac, freebsd and debian/ubuntu would be great.
I'm not a code golfer but I puzzled out this solution which makes a nice alias with some escaping:
python '-cimport json,sys;json.dump(json.load(sys.stdin),sys.stdout,separators=(",", ":"))'
I am new to mongodb and trying to export a collection in json format. When I executed the query which I learnt query from the online manual I get an error.
Input:
mongoexport -d test -c Nick -o c:/results.json --journal
output:
error parsing command line options: --dbpath and related flags are not supported in 3.0 tools.
I am not sure how to interpret the output.
I am using mongodb 3.0.4 version. I am implementing the query in command line and not in the shell.
The --journal option is the one causing the problem as that option is removed from Mongo 3.0.0 (http://docs.mongodb.org/manual/reference/program/mongoexport/#options)
Remove the --journal option and it should work fine.
I think the --journal flag is not supported in 3.0 versions.
The query worked perfectly without the --journal option.
Thanks anyway.