String manipulation Flashcards

1
Q
str="HELLO WORLD!"
echo "${str,}"
A

“hELLO WORLD!” (lowercase 1st letter)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
str="HELLO WORLD!"
echo "${str,,}"
A

“hello world!” (all lowercase)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
str="hello world!"
echo "${str^}"
A

“Hello world!” (uppercase 1st letter)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
str="hello world!"
echo "${str^^}"
A

“HELLO WORLD!” (all uppercase)

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

Transform strings
-c

A

Operations apply to characters not in the given set

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

Transform strings
-d

A

Delete characters

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

Transform strings
-s

A

Replaces repeated characters with
single occurrence

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

Transform strings
-t

A

Truncates

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

[:upper:]

A

All upper case letters

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

[:lower:]

A

All lower case letters

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

[:digit:]

A

All digits

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

[:space:]

A

All whitespace

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

[:alpha:]

A

All letters

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

[:alnum:]

A

All letters and digits

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

What will the following print?
~~~
echo “Danger Zone” | tr ‘[:lower:]’ ‘[:upper:]’
~~~

A

DANGER ZONE

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