Variables Flashcards

1
Q

how do you write a function?

A

name () {
commands
return
}

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

What is top down design?

A

Process of identifying top-level steps and developing increasing detailed views of those steps.

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

Shell functions are:

A

“Mini-scripts” located inside other scripts and can as as autonomous programs.

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

how do you start every script:

A

!/bin/bash

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

Run a script with what cmds:

A

./

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

How are variables written:

A

variable=value

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

a=z

A

Assign the string “z” to variable a.

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

b=”a string”

A

Embedded spaces must be within quotes

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

c=”a sting and $b”

A

Other expressions such variables can be expanded into a variable

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

d=”$(ls -l foo.txt)”

A

Variable is the result of the cmd

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

e=$((5 * 7))

A

Arithmetic expression

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

f=”\t\ta string\n”

A

Escape sequence such as tabs and new lines.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
Variable result of: 
filename="myfile" 
#mv "$filename" "${filename}1"
A

myfile1

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

Quoting in variables:

A

Good practice to enclose variables and cmd substitutions in double quotes to limit the effects of word-splitting by the shell.

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