Install jq JSON processor on Ubuntu 10.04

大兔子大兔子 提交于 2021-01-20 18:45:28

问题


Is there a way to install jq JSON processor on Ubuntu 10.04?

I Tried the usual sudo apt-get install jq but got the error E: Couldn't find package jq


回答1:


It is possible to perform sudo apt-get install jq however you need to inform the system where to find jq.

ℹ️ Note: Ubuntu 14+ users can skip to step 4! 🎉

Install

  1. Open your sources file in a text editor:

    sudo vim /etc/apt/sources.list
    
  2. Add the following line to the end of that file (note deb is not a command, more info):

    deb http://us.archive.ubuntu.com/ubuntu vivid main universe

  3. Then re-index apt-get so that it can find jq:

    sudo apt-get update
    
  4. Then do the normal install and you should be the proud new user of jq!

    sudo apt-get install jq
    

Test

Test it works! Try this to see it pretty print some example json

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"
}



回答2:


Since Ubuntu 16.04LTS xenial you do not need to modify /etc/apt/sources.list, just run

sudo apt-get install jq

jq 1.5 is in the official Debian and Ubuntu repositories.




回答3:


I think you're missing the repo: http://installion.co.uk/ubuntu/vivid/universe/j/jq/install/index.html




回答4:


Download & build from source as described in https://stedolan.github.io/jq/download/, last section called "From source on Linux, OS X, Cygwin, and other POSIX-like operating systems".




回答5:


(Updated)

I visited this page for Linux based jq installation and I tried below on Oracle Linux Server 7.3 which worked me:

sudo yum install jq


来源:https://stackoverflow.com/questions/33184780/install-jq-json-processor-on-ubuntu-10-04

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!