Question 340
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=52; threshold=12
if [ "$x" -lt "$threshold" ]; then echo branch-yes-04; else echo branch-no-04; fi
Which output line follows?
- branch-yes-04
- comparison-error-04
- no-output-04
- branch-no-04
Explanation
Correct Answer
D:Bash evaluates 52 -lt 12 as false using integer operands, so execution enters the else branch and prints branch-no-04. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-yes-04, but 52 -lt 12 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" -lt "$threshold" ] has two initialized integer operands (52 and 12), a valid test operator and the closing bracket required by Bash.
C:No-output is impossible here: the test of 52 and 12 via -lt selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 341
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=61; threshold=90
if [ "$x" -eq "$threshold" ]; then echo branch-yes-05; else echo branch-no-05; fi
Which output line follows?
- branch-no-05
- branch-yes-05
- comparison-error-05
- no-output-05
Explanation
Correct Answer
A:Bash evaluates 61 -eq 90 as false using integer operands, so execution enters the else branch and prints branch-no-05. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
B:The other branch would print branch-yes-05, but 61 -eq 90 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 (61 and 90), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 61 and 90 via -eq selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 342
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=83; threshold=72
if [ "$x" -ne "$threshold" ]; then echo branch-yes-06; else echo branch-no-06; fi
Which output line follows?
- branch-no-06
- branch-yes-06
- comparison-error-06
- no-output-06
Explanation
Correct Answer
B:Bash evaluates 83 -ne 72 as true using integer operands, so execution enters the then branch and prints branch-yes-06. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-no-06, but 83 -ne 72 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" -ne "$threshold" ] has two initialized integer operands (83 and 72), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 83 and 72 via -ne selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 343
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=14; threshold=20
if [ "$x" -gt "$threshold" ]; then echo branch-yes-07; else echo branch-no-07; fi
Which output line follows?
- branch-yes-07
- comparison-error-07
- branch-no-07
- no-output-07
Explanation
Correct Answer
C:Bash evaluates 14 -gt 20 as false using integer operands, so execution enters the else branch and prints branch-no-07. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-yes-07, but 14 -gt 20 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 (14 and 20), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 14 and 20 via -gt selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 344
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=88; threshold=31
if [ "$x" -ge "$threshold" ]; then echo branch-yes-08; else echo branch-no-08; fi
Which output line follows?
- branch-no-08
- comparison-error-08
- no-output-08
- branch-yes-08
Explanation
Correct Answer
D:Bash evaluates 88 -ge 31 as true using integer operands, so execution enters the then branch and prints branch-yes-08. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-no-08, but 88 -ge 31 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 (88 and 31), a valid test operator and the closing bracket required by Bash.
C:No-output is impossible here: the test of 88 and 31 via -ge selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 345
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=34; threshold=15
if [ "$x" -eq "$threshold" ]; then echo branch-yes-09; else echo branch-no-09; fi
Which output line follows?
- branch-no-09
- branch-yes-09
- comparison-error-09
- no-output-09
Explanation
Correct Answer
A:Bash evaluates 34 -eq 15 as false using integer operands, so execution enters the else branch and prints branch-no-09. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
B:The other branch would print branch-yes-09, but 34 -eq 15 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 (34 and 15), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 34 and 15 via -eq selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 346
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=51; threshold=87
if [ "$x" -gt "$threshold" ]; then echo branch-yes-10; else echo branch-no-10; fi
Which output line follows?
- branch-yes-10
- branch-no-10
- comparison-error-10
- no-output-10
Explanation
Correct Answer
B:Bash evaluates 51 -gt 87 as false using integer operands, so execution enters the else branch and prints branch-no-10. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-yes-10, but 51 -gt 87 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 (51 and 87), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 51 and 87 via -gt selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 347
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=84; threshold=22
if [ "$x" -ne "$threshold" ]; then echo branch-yes-11; else echo branch-no-11; fi
Which output line follows?
- branch-no-11
- comparison-error-11
- branch-yes-11
- no-output-11
Explanation
Correct Answer
C:Bash evaluates 84 -ne 22 as true using integer operands, so execution enters the then branch and prints branch-yes-11. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-no-11, but 84 -ne 22 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 (84 and 22), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 84 and 22 via -ne selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 348
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=74; threshold=26
if [ "$x" -ne "$threshold" ]; then echo branch-yes-12; else echo branch-no-12; fi
Which output line follows?
- branch-no-12
- comparison-error-12
- no-output-12
- branch-yes-12
Explanation
Correct Answer
D:Bash evaluates 74 -ne 26 as true using integer operands, so execution enters the then branch and prints branch-yes-12. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
A:The other branch would print branch-no-12, but 74 -ne 26 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 (74 and 26), a valid test operator and the closing bracket required by Bash.
C:No-output is impossible here: the test of 74 and 26 via -ne selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
Question 349
After the variables are assigned, this RHEL 10 Bash snippet runs:
#!/bin/bash
x=95; threshold=87
if [ "$x" -lt "$threshold" ]; then echo branch-yes-13; else echo branch-no-13; fi
Which output line follows?
- branch-no-13
- branch-yes-13
- comparison-error-13
- no-output-13
Explanation
Correct Answer
A:Bash evaluates 95 -lt 87 as false using integer operands, so execution enters the else branch and prints branch-no-13. The branch selection follows the numeric test, not lexical string comparison.
Incorrect Answers
B:The other branch would print branch-yes-13, but 95 -lt 87 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" -lt "$threshold" ] has two initialized integer operands (95 and 87), a valid test operator and the closing bracket required by Bash.
D:No-output is impossible here: the test of 95 and 87 via -lt selects exactly one echo statement, and both branches write a line to standard output under normal Bash execution.
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.
Red Hat Certified System Administrator (RHCSA) (EX200) Practice Tests