36
Quote Marks
Regular double quotes ("like these") make the shell ignore whitespace and count it all as one
argument being passed or string to use. Special characters inside are still noticed/obeyed.
Single quotes 'like this' make the interpreting shell ignore all special characters in whatever
string is being passed.
The back single quote marks (`command`) perform a different function. They are used when you
want to use the results of a command in another command. For example, if you wanted to set the
value of the variable contents equal to the list of files in the current directory, you would type the
following command: contents=`ls`, the results of the ls program are put in the variable contents.
Logic and comparisons
A command called test is used to evaluate conditional expressions, such as a if-then statement
that checks the entrance/exit criteria for a loop.
test expression
Or
[ expression ]
Numeric Comparisons
int1 -eq int2 Returns True if int1 is equal to int2.
int1 -ge int2
Returns True if int1 is greater than or equal to
int2.
int1 -gt int2 Returns True if int1 is greater than int2.
int1 -le int2 Returns True if int1 is less than or equal to int2
int1 -lt int2 Returns True if int1 is less than int2
int1 -ne int2 Returns True if int1 is not equal to int2
String Comparisons
str1 = str2 Returns True if str1 is identical to str2.
str1 != str2 Returns True if str1 is not identical to str2.
str Returns True if str is not null.
-n str
Returns True if the length of str is greater than
zero.
-z str
Returns True if the length of str is equal to zero.
(zero is different than null)
File Comparisons
-d filename Returns True if file, filename is a directory.
-f filename Returns True if file, filename is an ordinary file.
Commenti su questo manuale