2.4G 如何去掉.号后面部分
du -sh /data/backup/data/core|awk '{print $1}'|awk -F\. '{print $1}'
root@bwoil:/data/backup# sh -x clear.sh
+ bk_path=/data/backup/data/core
+ let size_sum=10
+ '[' 10 ']'
+ echo ok
ok
root@bwoil:/data/backup# more clear.sh
#!/bin/bash
bk_path="/data/backup/data/core"
#size_sum=`du -sh /data/backup/data/core|awk '{print $1}'|awk -F\. '{print $1}'`
let size_sum=10
if [ $size_sum -gt 20 ]
then
{
echo "ok"
}
fi
在 Bash 中使用 let 声明变量时,不需要在变量名前加 $。此外,在 if 语句中比较数字时,需要使用数字比较运算符
let size_sum=10 声明变量 size_sum 并赋值为 10。在 if 语句中使用 [ $size_sum -gt 20 ] 进行比较。-gt 是数字比较运算符,表示"大于"。