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.

OptionDescription
treat everything following as an argument, even if it begins with
–ndo not add ending newline to output
–predirect the given arguments to a co-process
–rignore  escape conventions
–Rignore  escape conventions; do not interpret – arguments as options (except –n)
–sredirect given arguments to history file
–unredirect 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:

PatternDescription
string == patternstring matches pattern
string != patternstring does not match pattern
string1 < stringASCII value of string1 is less than string2
string1 > stringASCII value of string1 is greater than string2
–z stringstring is zero in length, null parameter
–n stringstring 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.