1..判断命令历史中历史命令的总条目是否大于1000,如果大于,则显示“some command will gone”,否则显示OK
[root@localhost day4]# vim history.sh
#!/bin/bash
h=`history | awk '{print $1}'|tail -1`
if [ $h > 1000 ] ;then
echo "some command will gone"
else
echo "ok"
fi
![](https://i-blog.csdnimg.cn/blog_migrate/3aab3069a35f00a74013c530186cbe32.png)
h=`history |wc -l`
echo $count
#!/bin/bash
if [ $h -gt 200 ];then
echo "some command will cgone"
else
echo ok
fi
写在#前面表示先统计历史命令的数目
2.传入三个整数,并比较大小按照从小到大显示三个整数。
[root@localhost day4]# vim daxiao.sh
#!/bin/bash
read -p "输入3个整数:" n1 n2 n3
t=0
echo n1=$n1 n2=$n2 n3=$n3
if [ $n1 -gt $n2 ];then
t=$n1
n1=$n2
n2=$t
fi
if [ $n1 -gt $n3 ];then
t=$n1