How to install JQ on Mac by command-line?

前端 未结 5 642
长发绾君心
长发绾君心 2021-01-31 13:09

I need to know the most efficient way of installing JQ on Mac (el capitan). The code is downloaded to my mac but I would like to know how I can install and operate the via the c

相关标签:
5条回答
  • 2021-01-31 13:34

    You can install any application/packages with brew on mac. If you want to know the exact command just search your package on https://brewinstall.org and you will get the set of commands needed to install that package.

    First open terminal and install brew

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
    

    Now Install jq

    brew install jq
    
    0 讨论(0)
  • 2021-01-31 13:35

    For most it is a breeze, however like you I had a difficult time installing jq

    The best resources I found are: https://stedolan.github.io/jq/download/ and http://macappstore.org/jq/

    However neither worked for me. I run python 2 & 3, and use brew in addition to pip, as well as Jupyter. I was only successful after brew uninstall jq then updating brew and rebooting my system

    What worked for me was removing all previous installs then pip install jq

    0 讨论(0)
  • 2021-01-31 13:49

    On a Mac, the "most efficient" way to install jq would probably be using homebrew, e.g.

    brew install jq
    

    If you want the development version, you could try:

    brew install --HEAD jq
    

    but this has various pre-requisites.

    Detailed instructions are on the "Installation" page of the jq wiki: https://github.com/stedolan/jq/wiki/Installation

    The same page also includes details regarding installation from source, and has notes on installing with MacPorts.

    0 讨论(0)
  • 2021-01-31 13:52

    For CentOS, RHEL, Amazon Linux: sudo yum install jq

    0 讨论(0)
  • 2021-01-31 13:58

    The simplest way to install jq and test that it works is through brew and then using the simplest filter that merely formats the JSON

    Install

    brew is the easiest way to manage packages on a mac:

    brew install jq
    

    Need brew? Run the following command:

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    Failing that: instructions to install and use are on https://brew.sh/

    Test

    The . filter takes its input and produces it unchanged as output. This is the identity operator. (quote the docs)

    echo '{ "name":"John", "age":31, "city":"New York" }' | jq .
    

    The result should appear like so in your terminal:

    {
      "name": "John",
      "age": 31,
      "city": "New York"
    }
    
    0 讨论(0)
提交回复
热议问题