XK0-005 practice question 8 of 10
A file called testfile has both uppercase and lowercase letters: $ cat testfile ABCDEfgH IJKLmnoPQ abcdefgH ijklLMNopq A Linux administrator is…
Full set: 487 questionsA file called testfile has both uppercase and lowercase letters:
$ cat testfile ABCDEfgH IJKLmnoPQ abcdefgH ijklLMNopq
A Linux administrator is tasked with converting testfile into all uppercase and writing it to a new file with the name uppercase.
Which of the following commands will achieve this task?
The tr (translate) utility reads characters from standard input and replaces or deletes them before writing the results to standard output. To convert lowercase ASCII characters to uppercase, tr requires the source character set [a-z] as its first argument and the target replacement set [A-Z] as its second argument. The syntax tr '[a-z]' '[A-Z]' properly specifies this translation mapping. Redirection operators (such as outputfile) direct standard input from testfile and standard output to uppercase. Among the provided choices, option D specifies the correct tr command syntax and character range order required to perform lowercase-to-uppercase translation across all text input.
A. tr '(A-Z}' '{a-z}' uppercase: Uses incorrect character ranges and reverses translation order, mapping uppercase characters into lowercase instead of converting lowercase to uppercase.
B. echo testfile | tr "[Z-A]" "[z-a]" uppercase: Passes only the string literal "testfile" rather than file contents, and specifies invalid reverse character ranges [Z-A] and [z-a].
C. cat testfile | tr '{z-a)' '{Z-A}' uppercase: Uses invalid reverse character ranges (z-a) and improper brace syntax, which prevents valid character translation by tr.
GNU Coreutils Manual: Section 11.2 tr: Translate characters. https://www.gnu.org/software/coreutils/manual/html_node/tr-invocation.html
IEEE Std 1003.1-2017 (POSIX.1): tr utility specification. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/tr.html
Keep practicing
Take the free XK0-005 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other XK0-005 practice questions
- Question 1A Linux engineer needs to block an incoming connection from the IP address 2.2.2.2 to a s…
- Question 2A systems administrator identifies multiple processes in a zombie state. Which of the fol…
- Question 3An administrator made a change to a system's network configuration. Which of the followin…
- Question 4Which of the following can reduce the attack surface area in relation to Linux hardening?
- Question 5A Linux administrator needs to check extended permissions applied to the directory test. …
- Question 6A Linux systems administrator is updating code. After completing the update, the administ…
