the Commodore 64: 10 PRINT CHR$(205.5+RND(1)); : GOTO 10 C The following example is a C program (a winning entry in the "Best one-liner" category of the IOCCC). main(int c,char**v){return!m(v[1],v[2]);}m(char*s,char*t){return*t-42?*s?63==*t|*s==*t&&m(s+1,t+1):!*t:m(s,t+1)||*s&&m(s+1,t);} This one-liner program is a glob pattern matcher. It understands the glob characters `*' meaning `zero or more characters' and `?' meaning exactly one character, just like most Unix shells. Run it with two args, the string and the glob pattern. The exit status is 0 (shell true) when the pattern matches, 1 otherwise. The glob pattern must match the whole string, so you may want to use * at the beginning and end of the pattern if you are looking for something in the middle. Examples: $ ./a.out foo 'f??'; echo $? $ ./a.out 'best short program' '??st*o**p?*'; echo $? AWK The TAPL book contains 20 examples of one-liners at the end of the book's first chapter. Here are the very first of them: Print the total number of input lines (like wc -l): END { print NR } Print the tenth input line: NR == 10 Print the last field of every input line: { print $NF } J Here are examples in J: A function avg to return the average of a list of numbers: avg=: +/ % # Quicksort: quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#) Perl Here are examples in the Perl programming language: Look for duplicate words perl -0777 -ne 'print "$.: doubled $_\n" while /\b(\w+)\b\s+\b\1\b/gi' Find Palindromes in /usr/dict/words perl -lne 'print if $_ eq reverse' /usr/dict/words in-place edit of *.c files changing all foo to bar perl -p -i.bak -e 's/\bfoo\b/bar/g' *.c Many one-liners are practical. For example, the following Perl one-liner will reverse all the bytes in a file: perl -0777e 'print scalar reverse <>' filename While most Perl one-liners are imperative, Perl's support for anonymous functions, closures, map, filter (grep) and fold (List::Util::reduce) allows the creation of 'functional' one-liners. This one-liner creates a function that can be used to return a list of primes up to the value of the first parameter: my $z = sub { grep { $a=$_; !grep { !($a % $_) } (2..$_-1)} (2..$_[0]) } It can be used on the command line, like this: perl -e'$,=",";print sub { grep { $a=$_; !grep { !($a % $_) } (2..$_-1)} (2..$_[0]) }->(shift)' number to print out a comma-separated list of primes in the range