1. 首页
  2. Linux
  3. 运维

在 Shell 脚本中如何比较两个数字?



在 if-then 中使用测试命令( -gt 等)来比较两个数字。例如:

sh
#!/bin/bash
x=10
y=20
if [ x -gty ]
then
echo “x is greater than y”
else
echo “y is greater than x”
fi

发布者:admin,如若转载,请注明出处:https://ai1024.vip/37532.html

QR code
//