History

Invented by David Korn of AT&T Bell Labs in the mid-1980s.

Variable Expression and Modifier

Variable expressions can be tested and modified by using special modifiers.

Built-In Commands

print

Used instead of echo.

Option Description
treat everything following as an argument, even if it begins with
–n do not add ending newline to output
–p redirect the given arguments to a co-process
–r ignore  escape conventions
–R ignore  escape conventions; do not interpret – arguments as options (except –n)
–s redirect given arguments to history file
–un redirect arguments to file descriptor n.

More on -un:

Functions

Besides the Bash way of declaring functions, Korn also supports another way to declare functions:

# Bash syntax for function declaration
my_function() { commands; }
# Korn alternative syntax
function my_function { commands; }

Positional Parameters

Like Bourne, but with some C shell features.

Test Operator ([[ ]])

The Korn test command has additional operators and features over Bash.

String Operator Options:

Pattern Description
string == pattern string matches pattern
string != pattern string does not match pattern
string1 < string ASCII value of string1 is less than string2
string1 > string ASCII value of string1 is greater than string2
–z string string is zero in length, null parameter
–n string string is nonzero in length, nonnull parameter

let command and expression evaluation

let is a built-in command used to perform integer arithmetic.

Example: Using let

$ i=5
$ let i=i+1
$ print $i
6

typeset

typeset: Lets you assign variable types.

Example: Using typeset
# Floating point number assignment to variable.
typeset –F my_var

Note: On floating-points Korn supports integer and floating-point arithmetic.