moreutils completes the shell's toolbox

Slashdot it! Delicious Share on Facebook Tweet! Digg!
Sergei Koltovich, 123RF

Sergei Koltovich, 123RF


The moreutils package expands the standard tools for the shell with useful and sometimes exotic tools.

The shell lets you string together a myriad of discrete tools to solve complex tasks. Often the Coreutils utilities from the util-linux package are enough. There are, however, a number of situations that still don't have a standard solution in the form of a tool.

Together with some friends, Joey Hess has developed a set of programs grouped under the name moreutils [1] to fill some of these gaps. For the most part, these are specialized tools. Consequently, it is entirely possible that you have never heard of any of them. But if you spend a lot of time on the command line, then it would be a good idea to keep these small programs handy.

The current version of moreutils includes 15 programs (see Table 1). Each program is a nifty little tool that comes with a few options and is designed to accomplish a particular task. The tools were developed along the lines of classic Unix tools, so they work with a syntax that shares underlying similarities and concepts. There is a man page for each program; unfortunately, these are not very informative. See the "Installing moreutils" box for installation information.

Table 1


Category Utility
Start programs chronic , ifne , lckdo , parallel , zrun
Edit (text) files combine , isutf8 , ts , vidir
Tools for Pipes mispipe , pee , vipe , sponge
Error Handling errno , ifdata , isutf8 , mispipe

Installing moreutils

You can find moreutils in the repositories of Ubuntu, Debian, and their derivatives, however not in the most recent version 0.60. This version is available for download on the project website [1]. There are many other distributions, but not all, that also offer moreutils in their package source. If you are using a distribution that does not have this package, then you will need to compile the sources.

Grab the source code with:

git clone git://


In some situations, such as those involving scripts or cron jobs, the outputs of a program are irritating. chronic is helpful in resolving this problem. It expects the name of a program as its argument. chronic ignores the program's STDERR (error channel) and STDOUT (output channel) channels until an error actually occurs. You could do the same by using the construct

> /dev/null 2>&1

except that it would no longer be possible to preserve the output generated in the case of an error. The redirection to the null device simply would get rid of everything. Consequently, chronic is the better alternative.

Below is an example that uses chronic . Normally, this command line would create the desired EPUB file without generating any additional output. However, if an error does occur, you will get the entire output on the two channels, STDOUT and STDERR .

$ chronic a2x -v -fepub *.adoc

Two options control the behavior of chronic . The -e option, or STDERR triggering , makes sure that the program does not evaluate the executed program's return code. Instead it will decide whether errors have occurred on the basis of the output on STDERR . By default, a return code not equal to zero triggers an output.

chronic outputs a somewhat more detailed output if you use -v . In particular, this includes the return code for the executed program. In the process, it decides between the output on STDERR and STDOUT of the program that has been called.


The syntax for the ifne command is similar to that of chronic , and it also launches the program whose name is its first argument. However, it first evaluates the standard input in order to decide whether to actually start the program. Without any options, ifne will start the program only when the corresponding channel is not empty.

Below is a typical example from the man page. The administrator receives an email here if the find command finds at least one core file. The message directly contains the paths for the located files.

$ find . -name core | ifne mail -s "Core files found" root

ifne has one option, -n , that reverses its behavior. With this option, it will start the designated program only when the standard input is empty.

Buy this article as PDF

Express-Checkout as PDF

Pages: 7

Price $0.99
(incl. VAT)

Buy Ubuntu User

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content