在 Ubuntu 10.04 上安装 jq JSON 处理器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33184780/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 18:05:31  来源:igfitidea点击:

Install jq JSON processor on Ubuntu 10.04

jsonubuntuubuntu-10.04jq

提问by Ste-3PO

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

有没有办法在 Ubuntu 10.04 上安装 jq JSON 处理器?

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

我尝试了通常的sudo apt-get install jq但得到了错误E: Couldn't find package jq

回答by StefanJCollier

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

可以执行sudo apt-get install jq但是您需要通知系统在哪里可以找到 jq。

?? Note: Ubuntu 14+ users can skip to step 4!

?? 注意:Ubuntu 14+ 用户可以跳到第 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 debis not a command, more info):

    deb http://us.archive.ubuntu.com/ubuntuvivid 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
    
  1. 在文本编辑器中打开源文件:

    sudo vim /etc/apt/sources.list
    
  2. 将以下行添加到该文件的末尾(注意deb不是命令,更多信息):

    deb http://us.archive.ubuntu.com/ubuntu生动的主宇宙

  3. 然后重新索引 apt-get 以便它可以找到jq

    sudo apt-get update
    
  4. 然后进行正常安装,您应该是jq!

    sudo apt-get install jq
    

Test

测试

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

测试它是否有效!试试这个看看它漂亮地打印了一些示例 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"
}

回答by Nik

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

由于 Ubuntu 16.04LTS xenial你不需要修改/etc/apt/sources.list,只需运行

sudo apt-get install jq

jq 1.5is in the official Debianand Ubunturepositories.

jq 1.5位于官方DebianUbuntu存储库中。

回答by Hans Z.

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

从源代码下载和构建,如https://stedolan.github.io/jq/download/ 中所述,最后一节称为“从 Linux、OS X、Cygwin 和其他类似 POSIX 的操作系统上的源代码”。