String manipulation Flashcards
1
Q
str="HELLO WORLD!" echo "${str,}"
A
“hELLO WORLD!” (lowercase 1st letter)
2
Q
str="HELLO WORLD!" echo "${str,,}"
A
“hello world!” (all lowercase)
3
Q
str="hello world!" echo "${str^}"
A
“Hello world!” (uppercase 1st letter)
4
Q
str="hello world!" echo "${str^^}"
A
“HELLO WORLD!” (all uppercase)
5
Q
Transform strings
-c
A
Operations apply to characters not in the given set
6
Q
Transform strings
-d
A
Delete characters
7
Q
Transform strings
-s
A
Replaces repeated characters with
single occurrence
8
Q
Transform strings
-t
A
Truncates
9
Q
[:upper:]
A
All upper case letters
10
Q
[:lower:]
A
All lower case letters
11
Q
[:digit:]
A
All digits
12
Q
[:space:]
A
All whitespace
13
Q
[:alpha:]
A
All letters
14
Q
[:alnum:]
A
All letters and digits
15
Q
What will the following print?
~~~
echo “Danger Zone” | tr ‘[:lower:]’ ‘[:upper:]’
~~~
A
DANGER ZONE