目录
矩形
!/bin/bash
for ((a=1;a<=9;a++))
do
for ((b=1;b<=9;b++))
do
echo -n "*"
done
echo ""
done
直角三角形
#!/bin/bash
for ((a=1;a<=9;a++))
do
for ((b=1;b<=a;b++))
do
echo -n " "
done
for ((c=9;c>=a;c--))
do
echo -n "*"
done
echo ""
done
等腰三角形
#!/bin/bash
for ((a=1;a<=9;a++))
do
for ((b=9;b>=a;b--))
do
echo -n " "
done
#c=$[$a*2-1]
for ((c=1;c<=$[$a*2-1];c++))
do
echo -n "*"
done
echo ""
done
梯形
#!/bin/bash
for ((a=1;a<=9;a++))
do
for ((b=9;b>=a;b--))
do
echo -n " "
done
for ((c=1;c<=a;c++))
do
echo -n "*"
done
for ((d=1;d<=3;d++))
do
for ((e=1;e<=3;e++))
do
echo -n "*"
done
echo -n ""
done
echo ""
done
菱形
#!/bin/bash
for ((a=1;a<=9;a++))
do
for ((b=9;b>=a;b--))
do
echo -n " "
done
#c=$[$a*2-1]
for ((d=1;d<=$[$a*2-1];d++))
do
echo -n "*"
done
echo ""
done
for ((e=10;e>=1;e--))
do
for ((f=9;f>=e;f--))
do
echo -n " "
done
for ((g=1;g<=$[$e*2-1];g++))
do
echo -n "*"
done
echo ""
done
查看主机信息
#!/bin/bash
name=`hostname`
ip=`ifconfig ens33|awk /netmask/'{print $2}'`
os=`cat /etc/redhat-release`
kernel=`uname -r`
cpu=`lscpu|grep 型号名称:| tr -s " "| cut -d":" -f2`
mem=`free -hm |awk /Mem/'{print $2}'`
space=`lsblk |awk /disk/'{print $4}'|awk -F G '{print $1}'`
for i in $space
do
let sum=$[ $sum+$i ]
done
echo -e "$B主机名:$name"
echo -e "${B}IP地址:$ip"
echo -e "$B系统版本:$os"
echo -e "$B内核版本:$kernel"
echo -e "${B}cpu名称:$cpu"
echo -e "$B内存总大小:$mem"
echo -e "$B硬盘总大小:$space"