Computer Services & Repairs
Chicago and Suburbs
 

Table of Contents


 

7.01 Variable Commands

Symbol

Description

unset

Removes a variable


Example: removes a value of variable, without removing variable set the value to null

[bash]$ FIRSTANDLAST=null


readonly


Makes the value of a variable permanent

Options:

n/a without an argument, it displays a list of all readonly shell variables

declare and typeset


Assigns an attributes to a variable #( with option but no variable names as arguments, the command lists all shell variables that have the indicated attributes set.)

Options:

-a declares a variable as an array

-f declares a variable to be a function name

-i declares a variable to be type integer

-r makes a variable readonly; also readonly

-x exports a variable (makes it global-all shells); also export


Examples:

[bash]$ declare -x person=chris # makes it global

[bash]$ declare +x person=chris # removes an attribute from a variable

[bash]$ declare -r personal=chris # set the variable readonly (can not be undone)


export

and declare

Allows to create your own environmental variables (available to all child shells). To see exported variables in your shell type export with or wo option -p or declare -x.

printenv

Prints all or part of what is in environment (shows variable=values)

set

With no arguments or options will print all values of all variables know to the shell.

Options:

noclobber avoids overwriting files

noglob does not allow the use of wildards

nounset indicates an error when trying to use an undefined variable

vi enters vi editing mode

Example:

[bash]# set -o noclobber # ( avoids overwriting files)

[bash]# set +0 noclobber # (turn overwriting on )


echo$<va- riable>

echo value of a variable

Options:

$ indicates that you wish to see the value contained in that variable


Example:

[bash]$ echo $PS1 # will display a value of a PS1 variable

[bash]$ echo $PATH # will display a value of a PATH variable

[bash]$ echo $CDPATH # will display value of CDPATH variable


alias

Short name for a long or complex command. Syntax: alias [name[=value]]

Options:

n/a with no argument print the list of all aliases


Example:

[bash]$ alias ls=`ls-F'


unalias

Removes aliases

 
 
   

Copyright 2006 © Burnnet Computers LLC.