Linux bash script basics Flashcards

1
Q

if statement

A

if [[ condition ]]; then
body
elif [[ condition ]]; then

fi

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to create indexed array

A

array_name=(“one” “two” “three”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

how to create an associative array (and add new key pairs)

A

declare -A person

person[“name”]=Carson

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how to access associative array keys

A

${!associative_array[@]}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how to access associative array values

A

${associative_array[@]}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

for loop syntax

A

for x in list; do
code
done

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

command substitution

A

var=$(command)

passes the output of a command into a variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is a heredocument?

A

command &laquo_space;delimited (“eof”)
code
eof

sending inputs into a command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly