13,420
edits
Changes
→INVESTIGATION 4: CONTROL FLOW STATEMENTS
# To prove this, issue the following Linux command :<br><span style="color:blue;font-weight:bold;font-family:courier;">ls -l 10</span><br><br>You should notice a file called "'''10'''". The incorrectly issued '''test''' command '''used redirection'''<br>to create an empty file and assigning the exit status variable a ''TRUE'' value!<br><br>To prevent problems when issuing the '''test''' command when comparing numbers,<br>you can use the following options:<br>'''-lt''' (<), '''-le''' (<=), '''-gt''' (>), '''-ge''' (>=;), '''-eq''' (=), '''-ne''' (!=)<br><br>
# Issue the correct Linux command to properly test both values:<br><span style="color:blue;font-weight:bold;font-family:courier;">test $number1 -gt $number2</span><br><br>
# Issue a Linux command to display the value of '''$?'''.<br><br>You should notice that the exit status value is now ''FALSE '' which is the correct result.<br><br>
# The '''test''' command can be abbreviated by the square brackets '''[ ]''' which contains the '''test''' condition<br>within the square brackets. You need to have spaces between the brackets and the test condition;<br>otherwise, you will get a test error.<br><br>
# To generate a '''test error''', copy and paste the following '''test''' command:<br><span style="color:blue;font-weight:bold;font-family:courier;">[$number1 -gt $number2]</span><br><br>The reason for the error was that you need '''spaces''' between the '''square brackets''' and the '''test condition'''.<br><br>