Seven Flashcards

1
Q

Elements in a regular expression
RE is used in matching patterns
link:
http://tldp.org/LDP/abs/html/x17129.html

A

A character set
An anchor: these designate the position in the line of text that the RE is to match.
Modifiers: These expands or narrow the range of text of txt

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

sed command

A

sed in a nutshell is used to modify text content.

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

echo ${string/what/A}

A

This will substitute what in string by A

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

echo ${string:0:number}

A

Output 0:number length which doesn’t contain number

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

: ‘multiple lines here’

A

This is another way to write the comment here

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

cat > filename

A

output the comments to the filename

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

eval echo \${$var}

A

Usually, echo ${$var} is a syntax error, because we can only have one variable name in the curly parenthesis. eval takes the multiple strings as its input like they are typed from the command line when the $ will be translated. And then it puts them together and run them.

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

array initialization

A

array=(var1 var2 var3 var4)

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

what is the function of a code block

A

{code block} : I/O redirection

Note: redirect everything in the block

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

expr

A

expr arithmetic expression
ex. expr 3 * 2
sometimes, it has to be escaped

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

=~

A
=~ is used to match regex
ex.  
variable="This is a fine mess"
if [[ "$variable" =~ T.......fin*es* ]]
then
....
fi
double quote for T.....fin*es* is not necessary, and it may cause error
How well did you know this?
1
Not at all
2
3
4
5
Perfectly