Introduction to Unix

../_images/ksus2.jpg ../_images/UNIX_blocks1.jpeg

5.2. set

Linux for Programmers and Users, Sections 6.3 and 6.4.2

set

Without options, the name and value of each shell variable are displayed in a format that can be reused as input. The output is sorted according to the current locale. When options are specified, they set or unset shell attributes. Any arguments remaining after the options are processed are treated as values for the positional parameters and are assigned, in order, to $1, $2, … $n.

OPTIONS:

-o option-name

See the help page for more details. set -o vi is especially useful to get vi-style command line editing.

-v

Print shell input lines as they are read.

-x

Print commands and their arguments as they are executed. This is a useful debugging tool when writing shell script programs.

--

If no arguments follow this option, then the positional parameters are unset. Otherwise, the positional parameters are set to the arguments, even if some of them begin with a -.

For example, the following command will set the positional parameters to the columns from the output of ls -l. Note the use of Command Substitution in this example.

set -- $(ls -l $file)