Linux sort Command Examples

What is Linux sort? sort is a very useful command line utility used to sort the lines of a file or input stream. sort can be used to sort input by entire lines, single columns, or different column ranges in a variety of ways. Sorting by Entire Lines The default behavior of the sort command

read more

Count JSON Array Elements with jq

Sometimes when working with JSON on the command line, it is helpful to know how many elements exist in a JSON array. Fortunately this is easy to do with jq. jq is a lightweight, easy to use, command line JSON processor. *More information about jq can be found at https://stedolan.github.io/jq/manual/. Counting Array Elements in single

read more

Count the Number of Fields in JSON with jq

Sometimes when working with JSON on the command line, it is helpful to know how many fields exist in each document. Fortunately this is easy to do with jq. jq is a lightweight, easy to use, command line JSON processor. Counting Fields in single JSON String If you want to test individual JSON strings, you

read more

How to Display Window Tabs in Linux Screen

screen is a Linux program that allows users to create and manage multiple terminal instances. Using tabs to visually track multiple terminal windows is very convenient and luckily not too hard to do. Screen Window Tabs Example Here is an example of how to display window tabs in Linux screen. Simply add the below line

read more

How to Left Pad Numbers in AWK

Occasionally when working in a Linux/Unix environment comes the need to left pad numbers with zeros (add leading zeros to numbers). This is often done to make a series of numbers the same length. An example of doing this with awk can be seen below:

Sorting JSON by Value with JQ (Command Line JSON Processor)

jq is a lightweight command line JSON processor that is very easy to use. Sometimes it is helpful to see your data sorted by a particular field value. Luckily jq makes this easy to do. Here are some sample JSON records we will be working with in this post:

Sorting JSON by value with

read more

Using Variables in JQ (Command Line JSON Parser)

jq is a lightweight command line JSON processor that is very easy to use. Sometimes being able to use variables within a jq script is very useful. Below are various examples of doing this. Here is a sample record from the JSON file we use in most examples:

Using Simple Variables in jq To

read more

How to filter JSON records by value with jq

Often when working with JSON in a Linux/Unix environment, it is nice to be able to filter records based on the values of certain fields. jq is a lightweight command line JSON processor that is very easy to use. jq offers an easy way to filter JSON records based on field values with the select()

read more

How to Left Pad Numbers in Linux

There are many ways to left pad numbers in Linux. Usually this seems to be done by adding leading zeros in front of the main number. A few examples of doing this can be seen below: Using printf

Using AWK

Looping in Bash