How to use ‘awk’ to print columns from a text file (in any order) alvin March 26, 2018 - 4:03pm

One of my favorite ways to use the Unix awk command is to print columns of information from text files, including printing columns in a different order than they are in in the text file. Here are some examples of how awk works in this use case.

How to build a pipeline of external commands in Scala

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 12.14, “How to build a pipeline of external commands in Scala.”


You want to execute a series of external commands, redirecting the output from one command to the input of another command, i.e., you want to pipe the commands together.

How to execute (exec) external system commands in Scala

Scala exec FAQ: How do I execute external system commands in Scala?

When it comes to executing external system commands, Scala is a dramatic improvement over Java. The operators Scala makes available are much more like Perl or Ruby, and the operators themselves are consistent with traditional shell commands, and are therefore easy to remember. Let's take a look at a few examples.

An `egrep` example with multiple regular expressions

Summary: How to use the Linux egrep command with multiple regular expressions (regex patterns).

As a quick note here today, I just used the Linux egrep command to perform a case-insensitive search on multiple regular expressions (regex patterns). Really, what I did was a little more complicated:

locate -i calendar | grep Users | egrep -vi 'twiki|gif|shtml|drupal-7|java|PNG'

As you can see from that command, I did this:

The Linux more command

The Linux more command lets you view text files or other output in a scrollable manner. It displays the text one screenful at a time, and lets you scroll backwards and forwards through the text, and even lets you search the text.

Looking at a Linux file with the more command

A common way to use the Linux more command is to display the contents of a text file. Where you might normally "cat out" the contents of a text file with the cat command, like this:

Linux pipe command examples (command mashups)

One of my favorite things about Unix, Linux, and Mac OS X systems is that you can create your own commands by merging other commands. There isn't any formal name for these command combinations, other than to say that you're "piping" commands together, so I recently started referring to these as "command mashups".

Here's a simple pipeline command I use all the time, creating a long list of files and piping the output into the Linux more command:

Perl pipe - Reading from a pipeline with Perl

Perl pipeline FAQ: How can I read output from a shell command pipeline (pipe) in a Perl script?

One of the great things about Perl is that it's very easy to run operating system commands, and read the output of those commands. Perl makes this process very easy and natural - it's just like reading data from a file. In this article we'll demonstrate the process of running external commands from within Perl, and then reading the output of those commands.

Perl - How to read from a named pipe (fifo)

Perl FAQ: How can I write a Perl script to read from a named pipe (FIFO file)?

Here’s some code from a Perl program where I open up a named pipe (a FIFO file), then read data from that file until the end of time ... or at least until someone kills this program.