How to install jq on Ubuntu 17.04
How to install jq on Ubuntu 17.04
A jq program is a filter as it takes an input and produces an output. It is actually a lightweight and flexible command-line JSON processor. It can mangle the data format into any other format as it is written in C and it has zero runtime dependencies. This tutorial explains the installation procedure of jq on Ubuntu.
Installation procedure
To start the installation process, add the repo by executing the following command.
root@linuxhelp1:~# add-apt-repository ppa:eugenesan/ppa
This repository contains collection of customized, updated, ported and backported
packages for two last LTS releases and latest pre-LTS release.
Packages for older releases relocated to ppa:eugenesan/archive or deleted.
+-------------------------------------------------------------------------------------+
| Disclaimer:
+-------------------------------------------------------------------------------------+
* Packages in this a nd related PPAs are for personal use only.
They developed specifically for several custom environments and may not work for you.
* Usage of packages in this PPA, in some forms, might contradict licenses of software
packaged in this and related PPAs. End users and administrator are responsible for
runtime licensing and possible legal consequences.
* Some packages provided with their dependencies while some might require additional
Ubuntu repositories and external PPAs. Below is the list of
.
.
.
gpg: keybox ' /tmp/tmp5dz6r_wu/pubring.gpg' created
gpg: /tmp/tmp5dz6r_wu/trustdb.gpg: trustdb created
gpg: key E61380B28313A596: public key " Launchpad synergy+" imported
gpg: Total number processed: 1
gpg:imported: 1
OK
The repositories are added to the target system. Now update the repo by using the apt-get update command and execute it.
root@linuxhelp1:~# apt-get update
Get:1 http://ppa.launchpad.net/eugenesan/ppa/ubuntu zesty InRelease [15.4 kB]
Hit:2 http://in.archive.ubuntu.com/ubuntu zesty InRelease
Get:3 http://security.ubuntu.com/ubuntu zesty-security InRelease [89.2 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu zesty-updates InRelease [89.2 kB]
Get:5 http://ppa.launchpad.net/eugenesan/ppa/ubuntu zesty/main i386 Packages [3,924 B]
Get:6 http://ppa.launchpad.net/eugenesan/ppa/ubuntu zesty/main amd64 Packages [3,916 B]
Get:7 http://ppa.launchpad.net/eugenesan/ppa/ubuntu zesty/main Translation-en [3,140 B]
Hit:8 http://in.archive.ubuntu.com/ubuntu zesty-backports InRelease
Fetched 205 kB in 2s (83.1 kB/s)
Reading package lists... Done
The target system is updated with the required repositories. Next install the jq package and press y to continue with the installation process.
root@linuxhelp1:~# apt-get install jq -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
fonts-lato javascript-common libjs-jquery libruby2.3 msr-tools rake ruby ruby-did-you-mean ruby-minitest ruby-net-telnet
ruby-power-assert ruby-test-unit ruby2.3 rubygems-integration
Use ' apt autoremove' to remove them.
The following additional packages will be installed:
libjq1 libonig4
The following NEW packages will be installed:
jq libjq1 libonig4
0 upgraded, 3 newly installed, 0 to remove and 63 not upgraded.
Need to get 271 kB of archives.
After this operation, 1,090 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu zesty/universe amd64 libonig4 amd64 6.1.3-1 [114 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu zesty/universe amd64 libjq1 amd64 1.5+dfsg-2 [111 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu zesty/universe amd64 jq amd64 1.5+dfsg-2 [45.6 kB]
Fetched 271 kB in 2s (106 kB/s)
Selecting previously unselected package libonig4:amd64.
(Reading database ... 170104 files and directories currently installed.)
Preparing to unpack .../libonig4_6.1.3-1_amd64.deb ...
Unpacking libonig4:amd64 (6.1.3-1) ...
Selecting previously unselected package libjq1:amd64.
Preparing to unpack .../libjq1_1.5+dfsg-2_amd64.deb ...
Unpacking libjq1:amd64 (1.5+dfsg-2) ...
Selecting previously unselected package jq.
Preparing to unpack .../jq_1.5+dfsg-2_amd64.deb ...
Unpacking jq (1.5+dfsg-2) ...
Setting up libonig4:amd64 (6.1.3-1) ...
Setting up libjq1:amd64 (1.5+dfsg-2) ...
Processing triggers for libc-bin (2.24-9ubuntu2) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up jq (1.5+dfsg-2) ...
The jq package is installed in the target system. To know more about the options and command to be used in the jq, execute the following command.
root@linuxhelp1:~# jq
jq - commandline JSON processor [version 1.5-1-a5b5cbe]
Usage: jq [options] < jq filter> [file...]
jq is a tool for processing JSON inputs, applying the
given filter to its JSON text inputs and producing the
filter' s results as JSON on standard output.
The simplest filter is ., which is the identity filter,
copying jq' s input to its output unmodified (except for
formatting).
For more advanced filters see the jq(1) manpage (" man jq" )
and/or https://stedolan.github.io/jq
Some of the options include:
-c compact instead of pretty-printed output
-n use `null` as the single input value
-e set the exit status code based on the output
-s read (slurp) all inputs into an array apply filter to it
-r output raw strings, not JSON texts
-R read raw strings, not JSON texts
-C colorize JSON
-M monochrome (don' t colorize JSON)
-S sort keys of objects on output
--tab use tabs for indentation
--arg a v set variable $a to value < v>
--argjson a v set variable $a to JSON value < v>
--slurpfile a f set variable $a to an array of JSON texts read from < f>
See the manpage for more options.
For removing the package, execute the apt-get remove command and press y to continue the uninstallation of jq package and repositories.
root@linuxhelp1:~# apt-get remove jq -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
fonts-lato javascript-common libjq1 libjs-jquery libonig4 libruby2.3 msr-tools rake ruby ruby-did-you-mean ruby-minitest
ruby-net-telnet ruby-power-assert ruby-test-unit ruby2.3 rubygems-integration
Use ' apt autoremove' to remove them.
The following packages will be REMOVED:
jq
0 upgraded, 0 newly installed, 1 to remove and 63 not upgraded.
After this operation, 90.1 kB disk space will be freed.
(Reading database ... 170120 files and directories currently installed.)
Removing jq (1.5+dfsg-2) ...
Processing triggers for man-db (2.7.6.1-2) ...
Wasn' t that an easy installation procedure? jq can also be used to slice, filter, transform structured data.
Comments ( 0 )
No comments available