Question 350
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=47; threshold=79
if [ "$x" -lt "$threshold" ]; then echo branch-yes-14; else echo branch-no-14; fi
Which output line follows?
- branch-no-14
- branch-yes-14
- comparison-error-14
- no-output-14
Explanation
Correct Answer
B:Bash evaluates 47 -lt 79 as true using integer operands, so execution enters the then branch and prints branch-yes-14. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-no-14, but 47 -lt 79 is true; the script therefore chooses then. The Bash [] test returns a status before either echo runs.
C:There is no comparison syntax error: [ "$x" -lt "$threshold" ] has two initialized integer operands (47 and 79), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 47 and 79 via -lt selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 351
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=26; threshold=72
if [ "$x" -gt "$threshold" ]; then echo branch-yes-15; else echo branch-no-15; fi
Which output line follows?
- branch-yes-15
- comparison-error-15
- branch-no-15
- no-output-15
Explanation
Correct Answer
C:Bash evaluates 26 -gt 72 as false using integer operands, so execution enters the else branch and prints branch-no-15. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-yes-15, but 26 -gt 72 is false; the script therefore chooses else. The Bash [] test returns a status before either echo runs.
B:There is no comparison syntax error: [ "$x" -gt "$threshold" ] has two initialized integer operands (26 and 72), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 26 and 72 via -gt selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 352
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=57; threshold=86
if [ "$x" -lt "$threshold" ]; then echo branch-yes-16; else echo branch-no-16; fi
Which output line follows?
- branch-no-16
- comparison-error-16
- no-output-16
- branch-yes-16
Explanation
Correct Answer
D:Bash evaluates 57 -lt 86 as true using integer operands, so execution enters the then branch and prints branch-yes-16. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-no-16, but 57 -lt 86 is true; the script therefore chooses then. The Bash [] test returns a status before either echo runs.
B:There is no comparison syntax error: [ "$x" -lt "$threshold" ] has two initialized integer operands (57 and 86), a valid test operator and the closing bracket required by Bash.
C:No-output is impossible here: the test of 57 and 86 via -lt selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 353
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=36; threshold=52
if [ "$x" -lt "$threshold" ]; then echo branch-yes-17; else echo branch-no-17; fi
Which output line follows?
- branch-yes-17
- branch-no-17
- comparison-error-17
- no-output-17
Explanation
Correct Answer
A:Bash evaluates 36 -lt 52 as true using integer operands, so execution enters the then branch and prints branch-yes-17. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
B:The other branch would print branch-no-17, but 36 -lt 52 is true; the script therefore chooses then. The Bash [] test returns a status before either echo runs.
C:There is no comparison syntax error: [ "$x" -lt "$threshold" ] has two initialized integer operands (36 and 52), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 36 and 52 via -lt selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 354
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=1; threshold=77
if [ "$x" -gt "$threshold" ]; then echo branch-yes-18; else echo branch-no-18; fi
Which output line follows?
- branch-yes-18
- branch-no-18
- comparison-error-18
- no-output-18
Explanation
Correct Answer
B:Bash evaluates 1 -gt 77 as false using integer operands, so execution enters the else branch and prints branch-no-18. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-yes-18, but 1 -gt 77 is false; the script therefore chooses else. The Bash [] test returns a status before either echo runs.
C:There is no comparison syntax error: [ "$x" -gt "$threshold" ] has two initialized integer operands (1 and 77), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 1 and 77 via -gt selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 355
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=64; threshold=12
if [ "$x" -ne "$threshold" ]; then echo branch-yes-19; else echo branch-no-19; fi
Which output line follows?
- branch-no-19
- comparison-error-19
- branch-yes-19
- no-output-19
Explanation
Correct Answer
C:Bash evaluates 64 -ne 12 as true using integer operands, so execution enters the then branch and prints branch-yes-19. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-no-19, but 64 -ne 12 is true; the script therefore chooses then. The Bash [] test returns a status before either echo runs.
B:There is no comparison syntax error: [ "$x" -ne "$threshold" ] has two initialized integer operands (64 and 12), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 64 and 12 via -ne selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 356
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=40; threshold=39
if [ "$x" -ge "$threshold" ]; then echo branch-yes-20; else echo branch-no-20; fi
Which output line follows?
- branch-no-20
- comparison-error-20
- no-output-20
- branch-yes-20
Explanation
Correct Answer
D:Bash evaluates 40 -ge 39 as true using integer operands, so execution enters the then branch and prints branch-yes-20. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-no-20, but 40 -ge 39 is true; the script therefore chooses then. The Bash [] test returns a status before either echo runs.
B:There is no comparison syntax error: [ "$x" -ge "$threshold" ] has two initialized integer operands (40 and 39), a valid test operator and the closing bracket required by Bash.
C:No-output is impossible here: the test of 40 and 39 via -ge selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 357
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=17; threshold=24
if [ "$x" -ge "$threshold" ]; then echo branch-yes-21; else echo branch-no-21; fi
Which output line follows?
- branch-no-21
- branch-yes-21
- comparison-error-21
- no-output-21
Explanation
Correct Answer
A:Bash evaluates 17 -ge 24 as false using integer operands, so execution enters the else branch and prints branch-no-21. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
B:The other branch would print branch-yes-21, but 17 -ge 24 is false; the script therefore chooses else. The Bash [] test returns a status before either echo runs.
C:There is no comparison syntax error: [ "$x" -ge "$threshold" ] has two initialized integer operands (17 and 24), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 17 and 24 via -ge selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 358
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=38; threshold=69
if [ "$x" -eq "$threshold" ]; then echo branch-yes-22; else echo branch-no-22; fi
Which output line follows?
- branch-yes-22
- branch-no-22
- comparison-error-22
- no-output-22
Explanation
Correct Answer
B:Bash evaluates 38 -eq 69 as false using integer operands, so execution enters the else branch and prints branch-no-22. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-yes-22, but 38 -eq 69 is false; the script therefore chooses else. The Bash [] test returns a status before either echo runs.
C:There is no comparison syntax error: [ "$x" -eq "$threshold" ] has two initialized integer operands (38 and 69), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 38 and 69 via -eq selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 359
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=60; threshold=67
if [ "$x" -lt "$threshold" ]; then echo branch-yes-23; else echo branch-no-23; fi
Which output line follows?
- branch-no-23
- comparison-error-23
- branch-yes-23
- no-output-23
Explanation
Correct Answer
C:Bash evaluates 60 -lt 67 as true using integer operands, so execution enters the then branch and prints branch-yes-23. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-no-23, but 60 -lt 67 is true; the script therefore chooses then. The Bash [] test returns a status before either echo runs.
B:There is no comparison syntax error: [ "$x" -lt "$threshold" ] has two initialized integer operands (60 and 67), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 60 and 67 via -lt selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 360
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=92; threshold=21
if [ "$x" -gt "$threshold" ]; then echo branch-yes-24; else echo branch-no-24; fi
Which output line follows?
- branch-no-24
- comparison-error-24
- no-output-24
- branch-yes-24
Explanation
Correct Answer
D:Bash evaluates 92 -gt 21 as true using integer operands, so execution enters the then branch and prints branch-yes-24. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-no-24, but 92 -gt 21 is true; the script therefore chooses then. The Bash [] test returns a status before either echo runs.
B:There is no comparison syntax error: [ "$x" -gt "$threshold" ] has two initialized integer operands (92 and 21), a valid test operator and the closing bracket required by Bash.
C:No-output is impossible here: the test of 92 and 21 via -gt selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Red Hat Certified System Administrator (RHCSA) (EX200) Practice Tests