O'Reilly logo

Linux in a Nutshell, Fourth Edition by Aaron Weber, Stephen Figgins, Ellen Siever

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

set

Synopsis

                  set 
                  variable
                  =
                  value
                  set [options] variable[n]=
                  value
                  set 
                  variable
                  set
               

Set variable to value or, if multiple values are specified, set the variable to the list of words in the value list. If an index n is specified, set the nth word in the variable to value. (The variable must already contain at least that number of words.) If only variable is specified, set the variable to null. With no arguments, display the names and values of all set variables. See also “Predefined Shell Variables” earlier in this chapter. Only one of -f or -l can be given.

Options

-f

Set only the first occurrence of a variable to keep it unique.

-l

Set only the last occurrence of a variable to keep it unique.

-r

List only read-only variables, or set specified variable to read-only.

Examples

% set list=(yes no maybe)     
                  Assign a wordlist
% set list[3]=maybe           
                  Assign an item in existing wordlist
% set quote="Make my day"     
                  Assign a variable
% set x=5 y=10 history=100    
                  Assign several variables
% set blank                   
                  Assign a null value to blank

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required