*** Welcome to piglix ***

One-liner program


A one-liner program is textual input to the command-line of an operating system shell that performs some function in just one line of input.

The one-liner can be

Certain dynamic scripting languages such as AWK, sed, and Perl have traditionally been adept at expressing one-liners. Specialist shell interpreters such as these Unix shells or Windows PowerShell, allow for the construction of powerful one-liners.

The use of the phrase one-liner has been widened to also include program-source for any language that does something useful in one line.

The word One-liner has two references in the index of the book The AWK Programming Language (the book is often referred to by the abbreviation TAPL). It explains the programming language AWK, which is part of the Unix operating system. The authors explain the birth of the one-liner paradigm with their daily work on early Unix machines:

The 1977 version had only a few built-in variables and predefined functions. It was designed for writing short programs […] Our model was that an invocation would be one or two lines long, typed in and used immediately. Defaults were chosen to match this style […] We, being the authors, knew how the language was supposed to be used, and so we only wrote one-liners.

Notice that this original definition of a one-liner implies immediate execution of the program without any compilation. So, in a strict sense, only source code for interpreted languages qualifies as a one-liner. But this strict understanding of a one-liner was broadened in 1985 when the IOCCC introduced the category of Best One Liner for C, which is a compiled language.


...
Wikipedia

...