Linux and Unix ksh command

Quick links

About ksh
Syntax
Examples
Related commands
Linux and Unix main page

About ksh

Runs a Korn shell / Korn script.

Syntax

ksh [-a] [-b] [-C] [-e] [-f] [-h] [-i] [-k] [-m] [-n] [-o] [-p] [-s] [-t] [-u] [-v] [-x] [+ o option ] [+A name] [ arg ]

 

-aAll subsequent variables that are defined are automatically exported.
-bCauses the shell to notify the user asynchronously of background job completions. The following message will be written to standard error:

"[%d]%c %s%s\n", <job-number>, <current>, <status>, <job-name>

where the fields are as follows:

<current> The character + identifies the job that would be used as a default for the fg or bg utilities; this job can also be specified using the job_id %+ or %%. The character - identifies the job that would become the default if the current default job were to exit; this job can also be specified using the job_id %-. For other jobs, this field is a space character. At most one job can be identified with + and at most one job can be identified with -. If there is any suspended job, then the current job will be a suspended job. If there are at least two suspended jobs, then the previous job will also be a suspended job.

<job-number> A number that can be used to identify the process group to the wait , fg , bg , and kill utilities. Using these utilities, the job can be identified by prefixing the job number with %.

<status> Unspecified.

<job-name> Unspecified.

When the shell notifies the user a job has been completed, it may remove the job's process ID from the list of those known in the current shell execution environment. Asynchronous notification will not be enabled by default.

-C-C Prevent existing files from being overwritten by the shell's > redirection will override this noclobber option for an individual file.
-eIf a command has a non-zero exit status, execute the ERR trap, if set, and exit. This mode is disabled while reading profiles.
-fDisables file name generation.
-hEach command becomes a tracked alias when first encountered.
-kAll variable assignment arguments are placed in the environment for a command, not just those that precede the command name.
-mBackground jobs will run in a separate process group and a line will print upon completion. The exit status of background jobs is reported in a completion message. On systems with job control, this flag is turned on automatically for interactive shells.
-nRead commands and check them for syntax errors, but do not execute them. Ignored for interactive shells.
-oThe following argument can be one of the following option names:
allexportSame as -a.
errexitSame as -e.
bgniceAll background jobs are run at a lower priority. This is the default mode.
emacsPuts you in an emacs style in-line editor for command entry.
gmacsPuts you in a gmacs style in-
line editor for command entry.
ignoreeofThe shell will not exit onEOF. The command exit must be used.
kewordSame as -k.
markdirsAll directory names resulting from file name generation have a trailing / appended.
monitorSame as -m.
noclobberPrevents redirection > from truncating existing files. Require >| to truncate a file when turned on. Equivalent to -C.
noexecSame as -n.
noglobSame as -f.
nologDo not save function definitions in history file.
notifyEquivalent to -b.
nounsetSame as -u.
privileged  Same as -p.
verboseSame as -v.
trackallSame as -h.
viPuts you in insert mode of a vi style in-line editor until you hit escape character 033.  This puts you in control mode. A return sends the line.
virawEach character is processed as it is typed in vi mode.
xtraceSame as -x.

If no option name is supplied, the current option settings are printed.

-pDisables processing of the $HOME/.profile file and uses the file /etc/suid_profile instead of the ENV file. This mode is on whenever the effective uid is not equal to the real uid, or when the effective gid is not equal to the real gid. Turning this off causes the effective uid and gid to be set to the real uid and gid.
-sSort the positional parameters lexicographically.
-tExit after reading and executing one command.
-uTreat unset parameters as an error when substituting.
-vPrint shell input lines as they are read.
-xPrint commands and their arguments as they are executed.
-Turns off -x and -v flags and stops examining arguments for flags.
--Do not change any of the flags; useful in setting $1 to a value beginning with -. If no arguments follow this flag then the positional parameters are unset. 

Using + rather than - causes these flags to be turned off. These flags can also be used upon invocation of the shell. The current set of flags may be found in $-. Unless -A is specified, the remaining arguments are positional parameters and are assigned, in order, to $1 $2 .... If no arguments are given, the names and values of all variables are printed on the standard output.

+A nameArray assignment. Unset the variable name and assign values sequentially from the list arg. If +A is used, the variable name is not unset first.
argAdditional arguments.

Examples

ksh

If supported would open the Korn shell.

Related commands

bash
csh
sh