BASH SCRIPTING Flashcards

1
Q
Consider the following script
	#!/bin/bash
	echo 'file redirection is easy' > file1
	cat < file1 > file2
	echo "as easy as pie" >> file2
	cat file2 | sort
	What is the output from the last line of the script?

a. as easy as pie file redirection is easy
b. file redirection is easy
c. as easy as pie
d. file redirection is easy as easy as pie

A

a. as easy as pie file redirection is easy

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

What is the output from the following commands?
$ A=5
$ B=A+5
$ echo $B

a. 10
b. 5
c. A+5
d. 55

A

c. A+5

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

What is the output of the following commands?
$ DATA=’some stuff’
$ /bin/sh
$ echo $DATA

a. some
b. stuff
c. some stuff
d. A blank line

A

d. A blank line

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

Which of the following regular expressions would find Orville or Wilbur Wright on a line by itself?

a. $(Orville|Wilbur) Wright^
b. ^(Orville or Wilbur) Wright$
c. ^(Orville|Wilbur) Wright$
d. $[Orville|Wilbur] Wright$^

A

c. ^(Orville|Wilbur) Wright$

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

Which regular expression would match everything between double quotes in this example text? His nicknames are “Matt” and “Dawg”

a. “[^”]+”
b. “[A-Z]
c. “.

d. “*”

A

a. “[^”]+”

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