脚本1:
#vim b.sh
#!/bin/bash
#查询本机ip,根磁盘剩余容量,以及内存剩余容量
cecho(){
echo -e "\033[$1m$2\033[0m"
}
IP=`ifconfig |awk -F "[: ]" ‘/inet addr/{print $13}‘`
echo "本机IP为:"
cecho 33 "$IP"
disk=`df -h |awk -F "[ ]" ‘/\/$/{print $19}‘`
echo "根磁盘剩余容量"
cecho 34 $disk
mem=`free -h |awk ‘/+/{print $4}‘`
echo "内存剩余容量为"
cecho 34 $mem
脚本2:(1到100质数和)
#!/bin/bash
for i in `seq 6`
do
for a in `factor $i | awk -F"[ :]" ‘{if(NF == 3) print $1} ‘`
do
s=$[0+$a]
done
done
echo $s
脚本3:(1到100质数)
#!/bin/bash
#1到100的质数
for i in `seq 100`
do
factor $i | awk -F"[ :]" ‘{if(NF == 3) print $1 }‘
done
脚本4:(1到100)
#seq 100 |echo $[`tr "\n" "+"` 0]
5050
# seq 5 |echo $[`tr "\n" "*"`1]
120
# seq 1 2 100 |echo "$[`tr "\n" "+"` 0]"
2500
# seq 0 2 100 |echo "$[`tr "\n" "+"` 0]"
2550
# seq 1 2 5 |echo $[`tr "\n" "+"` 0]
9
#/bin/bash
#1到100和
sum=0
#for i in `seq 100`
for i in {1..100}
do
sum=$[sum+i]
done
echo 1到100总和是:$sum
本文出自 “12336621” 博客,请务必保留此出处http://12346621.blog.51cto.com/12336621/1914785
原文地址:http://12346621.blog.51cto.com/12336621/1914785