In Linux shell programming, it is often used to determine whether a string is equal, the operator that can be used to determine whether a string is equal (equal), ' (not equal To), ' (less than), ' (Less -eq -ne -lt -le than or equal -gt to), ' (greater than) or ' -ge (greater than or equal to), and =,==,!=,<,>.
In the Bash guide, the letter operator and the symbol operator have different arguments in English, and the symbol operator uses a string, and the letter operator is ARG.
# http://www.gnu.org/software/bash/manual/bashref.html
string1=string2
True if the strings is equal. ' = should is used with the test
command for POSIX conformance.
string1!=string2
True if the strings is not equal.
string1<string2
True if string1 sorts before string2 lexicographically.
string1>string2
True if string1 sorts after string2 lexicographically.
arg1OParg2
OP
is one of ', ', ', ', ', ', -eq -ne -lt -le -gt or ' -ge . These arithmetic binary operators return true if arg1 is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal arg2 to, respectively. Arg1 And may be arg2 positive or negative integers.
In practical programming, when using the letter operator, although the effect is the same as the symbol operator, it produces an error "[[: Arg2:syntax Error:operand Expected (Error token is" arg2 ")".
As the original
[["-eq" "]] && echo" Delete all spaces and comments of specialized file, using with [email protected] Filena Me "&& exit 1
Revision changed to
[["] = = ["]] && echo "Delete all spaces and comments of specialized file, using with [email protected] Filenam E "&& exit 1
will not be prompted again.
Comes with a handy little script that uses grep to remove space and comment (#), which is simple and practical.
#!/bin/bash # Delete all spaces and comments of specialized file, using with [email protected] filename [["] = =" " ] && echo "Delete all spaces and comments of specialized file, using with [email protected] filename" && Exit 1 grep-v \# $ | Grep-v ^$
Add to the operating system:
Cat > Delsc.sh << eof #!/bin/bash # Delete all spaces and comments of specialized file, using with [email PR otected] filename [["\$1"-== "]] && echo" Delete all spaces and comments of specialized file, using with \[ Email protected] filename "&& exit 1 grep-v \# \$1 | Grep-v ^$ EOF chmod +x./delsc.sh \mv DELSC.SH/USR/LOCAL/BIN/DELSC which DELSC CAT/USR/LOCAL/BIN/DELSC
Usage:
DELSC filename
This article is from "Communication, My Favorites" blog, please make sure to keep this source http://dgd2010.blog.51cto.com/1539422/1542048