Linux bash script basics Flashcards
1
Q
if statement
A
if [[ condition ]]; then
body
elif [[ condition ]]; then
fi
2
Q
How to create indexed array
A
array_name=(“one” “two” “three”)
3
Q
how to create an associative array (and add new key pairs)
A
declare -A person
person[“name”]=Carson
4
Q
how to access associative array keys
A
${!associative_array[@]}
5
Q
how to access associative array values
A
${associative_array[@]}
6
Q
for loop syntax
A
for x in list; do
code
done
7
Q
command substitution
A
var=$(command)
passes the output of a command into a variable
8
Q
what is a heredocument?
A
command «_space;delimited (“eof”)
code
eof
sending inputs into a command