Reading the Linux Shell written by othersCodeSuddenly found a lot of code similar to the following format:
["$ Pro" = "1"] & ckssl = "-- SSL" [-n "$ IP"] & ckip = "-h $ IP" [-n" $ port "] & ckport ="-p $ port"
I didn't understand why I wrote this in the first place.
I only know that [] is equivalent to test.
After consulting a senior, I suddenly realized that I ignored the principle of execution &.
If & (and operator) is executed from left to right, the expression on the right is executed only when the execution result on the left is true. Otherwise, the expression on the right is not executed.
This format can cleverly Replace the if statement to simplify the code.
For the same purpose, if you use if:
If ["$ pro" = "1"]; then ckssl = "-- SSL" fi;
Three lines of code are required. In fact, the execution efficiency of the two methods should be the same.C LanguageThe example of a one-to-one operation in a left-side navigation pane is more efficient than the operation in step 2.
Here, you need to execute the expressions in [] and then judge the result value of the expression.