Linux and Unix set command

Quick links

About set
Syntax
Examples
Related commands
Linux and Unix main page

About set

In C shell sets the value of an environment variable.

Syntax

set [--] [-a] [-e] [-f] [-h] [-k] [-m] [-n] [-p] [-s] [-t] [-u] [-v] [-x] [ -o option ] [ -A name ] [arg]

--Do not change any of the flags; useful in setting $1 to -.
-aMark variables which are modified or created for export.
-eExit immediately if a command exits with a nonzero exit status.
-fDisable file name generation.
-hLocate and remember function commands as functions are defined (function commands are normally located when the function is executed).
-kAll keyword 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 but do not execute them.
-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 variables as an error when substituting.
-vPrint shell input lines as they are read.
-xPrint commands and their arguments as they are executed.
-o optionThe 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. emacs Puts 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 on end-of-file. The command exit must be used.
keywordSame 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.
noexecSame as -n.
noglobSame as -f.
nologDo not save function definitions in history file.
nounsetSame as -u.
privilegedSame as -p.
verboseSame as -v.
trackballSame 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.
-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.

* Using + rather than - causes these flags to be turned off.

Examples

setenv PATH "/bin:/usr/bin:/usr/sbin:ucb/bin"

Sets the environment path to search for files in the /bin, /usr/bin, /usr/sbin and usb/bin directory.

Related commands

csh
ksh
setenv
sh