linux-tutorial/codes/shell/示例脚本/逻辑控制/错误的使用大于小于号.sh
2019-10-10 08:56:31 +08:00

16 lines
358 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 大于小于号必须转义否则shell会将它们当做重定向符号而把字符串值当做文件名处理
# 大于小于号顺序和sort命令所采用的有所不同
# mis-using string comparisons
val1=baseball
val2=hockey
if [ $val1 > $val2 ]
then
echo "$val1 is greater than $val2"
else
echo "$val1 is less than $val2"
fi