3.3 Command Line - Turning Commands into a Script Flashcards

1
Q

Shell scripts start with the following sequence to define the interpreter:

A) /bin/bash
B) #!
C) $#
D) !#

A

!

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

Which of these is a valid for loop?

A) while [ $i -le $count ]; echo $i && count=$[$count+1]; done

B) for i in {1..10}; do echo $i; done

C) for i in one two three; echo $1

D) loop 1-10; echo $i

A

for i in {1..10}; do echo $i; done

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

Which of the following sets the variable myvar equal to Apple?

A) myvar==”Apple”
B) $myvar=”Apple”
C) $myvar==”Apple”
D) myvar=”Apple”

A

myvar=”Apple”

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

Which of these is a valid if statement?

A) if $i=”1”; echo $i

B) if [ $i -eq true ] echo $i; done

C) if $i = “”; echo $i; d=fi

D) if [ -n $i ]; then echo $i; fi

A

if [ -n $i ]; then echo $i; fi

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