LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

ksh

Korn shell, combining features of sh and csh

TLDR

Start Korn shell
$ ksh
copy
Run a script
$ ksh [script.ksh]
copy
Run a command string
$ ksh -c "[command]"
copy
Start a login shell
$ ksh -l
copy
Start a restricted shell
$ ksh -r
copy
Enable POSIX compliance mode
$ ksh -o posix
copy
Enable vi-style line editing
$ ksh -o vi
copy

SYNOPSIS

ksh [options] [script] [args...]

DESCRIPTION

ksh is the Korn shell, combining features of the Bourne shell (sh) and C shell (csh). It provides advanced scripting capabilities with interactive command-line editing, command history, job control, and aliases.The shell supports both vi and emacs editing modes, associative and indexed arrays, arithmetic evaluation, coprocesses, and pattern matching. ksh93 is the most widely used version; ksh2020 is a more recent release.

PARAMETERS

SCRIPT

Script file to execute.
-c CMD
Execute command string.
-l
Login shell (reads profile files).
-r
Restricted shell (limits operations like cd and path changes).
-s
Read commands from standard input.
-o OPTION
Set shell option (e.g., vi, emacs, posix, noclobber, errexit).
+o OPTION
Unset shell option.
-i
Force interactive shell mode.
-n
Read commands but do not execute them (syntax check).
-x
Print commands and arguments as they are executed (trace mode).
-e
Exit immediately if a command exits with non-zero status.
-v
Print shell input lines as they are read.
--help
Display help information.

CAVEATS

Multiple implementations exist (ksh88, ksh93, mksh, pdksh). Behavior may differ subtly between implementations and from bash. POSIX compatible when invoked with `-o posix`.

HISTORY

The Korn shell was created by David Korn at Bell Labs in the early 1980s, influencing many modern shells including bash and zsh.

SEE ALSO

bash(1), sh(1), zsh(1), tcsh(1)

Copied to clipboard
Kai