在Ubuntu 10.04上安装jq JSON处理器

z31licg0  于 2023-02-18  发布在  其他
关注(0)|答案(5)|浏览(383)

有没有办法在Ubuntu 10.04上安装jq JSON处理器?
我尝试了通常的sudo apt-get install jq,但得到错误E: Couldn't find package jq

lsmepo6l

lsmepo6l1#

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

  • ️* 注意**:Ubuntu 14+用户可以跳到步骤3!🎉

安装

1.在文本编辑器中打开源文件:

sudo vim /etc/apt/sources.list

1.将以下行添加到该文件的末尾(注意deb不是命令,more info):
deb http://us.archive.ubuntu.com/ubuntu生动的主宇宙
1.然后重新索引apt-get,以便它可以找到jq

sudo apt-get update

1.然后进行正常安装,您应该是jq的新用户!

sudo apt-get install jq

测试

测试它的工作原理!试试这个,看看它漂亮的打印一些例子json

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

在您的终端中,结果应该如下所示:

{
  "name": "John",
  "age": 31,
  "city": "New York"
}
busg9geu

busg9geu2#

由于Ubuntu 16.04LTS xenial,您无需修改/etc/apt/sources.list,只需运行

sudo apt-get install jq

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

kiz8lqtg

kiz8lqtg4#

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

wn9m85ua

wn9m85ua5#

如果您没有sudo权限,请执行以下操作:

#!/usr/bin/env bash

# conda activate jq_install_env

# - Install jq without sudo
# Clone the jq repository from GitHub
cd $HOME
git clone https://github.com/stedolan/jq.git $HOME/jq
cd $HOME/jq
git submodule update --init

# Compile jq from source
cd $HOME/jq
autoreconf -fi
./configure --with-oniguruma=builtin --disable-maintainer-mode --prefix=$HOME/.local
make -j8 && make check
make install
ls $HOME/.local
ls $HOME/.local/bin

# Add the directory where the jq binary file is located to your PATH environment variable
echo 'PATH=$PATH:~/.local/bin/' >> $HOME/.bashrc.lfs
export PATH=$PATH:~/.local/bin/
echo $PATH | tr ':' '\n'

# Reload your shell configuration file to update your PATH environment variable
source $HOME/.bashrc.lfs

# Verify that jq is installed and working
jq --version

参考:https://suzyahyah.github.io/misc/2020/03/31/jq-without-sudo.html
如果连接器死亡:

Landing Page...
AboutCategoriesAdvisors
Recipe for building jq from source without admin(sudo) rights
Mar 31, 2020

This took me some time to install. Just putting it out there in case it helps someone.
Get the latest jq from github

git clone https://github.com/stedolan/jq.git

Update submodules (onigurama)

git submodule update --init

Copy missing auxiliary files

autoreconf -fi

Install into {YOUR_HOME_DIR} with onigurama (regex library)

./configure --with-oniguruma=builtin --disable-maintainer-mode --prefix={YOUR_HOME_DIR}.local

Check that we have all the dependencies downloaded and install

make -j8 && make check

make install

Finally, add this to your ~/.bashrc and to call jq from anywhere. Remember to >source ~/.bashrc and you should be good to go.

export PATH=$PATH:~/.local/bin/

« The Sigmoid in Regression, Neural Network Activation and LSTM GatesA minimum keystroke (py)Debugger for Lazy ML/DS people who don't IDE »
Quality means doing it right when no one is looking - Henry Ford
 suzyahyah
 suzyahyah
The best time to plant a tree was 20 years ago. The second best time is now. - Japanese proverb

Since October 2017

相关问题