105.1 Lesson 2 Flashcards
Where does a shell/local variable live?
In the shell in which they were created.
Where does an environment/global variable live?
In the shell where they were created and in children shells and/or processes.
Where do you configure variables, aliases and functions for a shell?
In startup files.
Accessing the value of a variable is called
variable referencing
How do you reference the variable distro?
$distro
Which characters may the name of a variable contain?
a-Z
A-Z
0-9
underscore _
What is wrong with the variable 1distro?
It starts with a number.
What is wrong with the variable “my distro”=zorinos?
It contains a space
The value of a variable is also called
reference
Which characters may the value of a variable contain?
a-z A-Z 0-9 most other characters $ ! * . / etc.
What is wrong with the following variable value?
distro=zorin 12.4
It contains a space and is not enclosed in quotes.
When must a variable value be enclosed in quotes?
When it contains < > or | (pipe symbol)
Are single and double quotes always interchangeable?
no
What do the semantics of single and double quotes depend on?
If they are used for assigning or for referencing
How do single quotes interpret characters of a variable’s value in the context of variable assignment?
literally
How is $lizard interpreted during variable assignment when using double quotes?
The variable $lizard is substituted with its value.
What happens to initial and extra spaces in a variables value during variable referencing when no double quotes are used?
The spaces get lost.
How do you avoid field splitting and pathname expansion when referencing a variable?
echo “$lizard”
Variables in bash are also called
shell parameters
variable referencing is also called
shell parameter expansion
How many expansions does shell parameter expansion consist of?
7
Name one expansion that is carried out during shell parameter expansion?
word splitting
What happens in the word splitting process of shell parameter expansion?
The result of the other expansions is split into words using the shell parameter $IFS.
What is the default value of $IFS?