Five:SPECIAL CHARACTERS Flashcards

1
Q

semicolon ;

A

A semicolon allows to write multiple lines of command in one line.
Note: there is a space after ever semicolon

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

double semicolon ;;

A

The double semicolon is used in the case switch expression

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

The case expression

A
case $variable in
var1) statement ;;
var2) statement ;;
*) statement ;;
esac
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

dot .

A

as a component of a filename

also file is hidden if it is prefixed by a dot

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

dot . in character match

A

match only one character

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

double quote

A

preserve most of the special chracter

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

comma operator

A

all evaluated, but only the last one returned

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

comma in concatenation

A

/usr/{,share/}bin
represents
/usr/bin
/usr/share/bin

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

command colon

A

”:” is itself a bash built-in and may be equivalent to true
:&raquo_space; filename This combination do nothing to an existing file but create it if it does not exist
: > filename This empty a file

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

colon as a field separator

A

PATH=PATH1:PATH2

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

a double parenthesis

A

((condition ? state1 : state2))

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

${parameter?err_msg}, ${parameter:?err_msg}

A

if parameter is set, use it, else print err_msg

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

? serves as a single wild card

A

?name

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

listing arguments

A

”$@” and “$*” note that these two should be quoted

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

$?

A

exit status

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

(command group)

A

The variables in the parenthesis is local inside the parenthesis

17
Q

cat {file1,file2,file3} > filename

no space is allowed in the bracket

A

this combine these three files to just one file

18
Q

cp file{extension1,extension2}

A

this copies two files with the different extension

19
Q

block of code

A
{command block}
the content in the block can be seen by the remain of the script  unlike the condition in the parenthesis
{read line1
read line2
}
20
Q

equivalence of test

A

[]
[
test
[[]]
difference between [] and [[]]. The [] doesn’t evaluate
[[]] evaluates
There must be a space between the [ and the chactaters
if you want to use && and || operator, best use [[ ]]

21
Q

if command expression

A

if takes the exit value from the command expression

22
Q

(()) and $[]

A

evaluate integer expansion

23
Q

cd -

A

get into the previous working directory

24
Q

previous working directory

A

~-

25
Q

current working directory

A

~+

26
Q

in the test expression

A

test 5 > 2 && statement || statement

The both sides of the > must contain a space

27
Q

where should we put ! in the test expression

A

right after the keyword test

28
Q

what is $()

A

as far as I can guess, $(command) this will give the output of command as the input

29
Q

what is the format for find

A

find path -name pattern