当前位置:网站首页>shell脚本
shell脚本
2022-08-10 21:25:00 【白给超人】
目录
矩形
!/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"

边栏推荐
- 黑猫带你学Makefile第13篇:Makefile编译问题合集
- The use of TortoiseSVN little turtle
- Detailed explanation of the use of Oracle's windowing function (2)
- ENVI自动生成地面控制点实现栅格影像的自动地理配准
- D. Game With Array
- Conditional Statements of Shell Programming (2)
- 翻译科技论文,俄译中怎样效果好
- 这些不可不知的JVM知识,我都用思维导图整理好了
- 2022.8.8 Selected Lectures on Good Topics (Number Theory Field)
- C. Social Distance
猜你喜欢

shell编程之免交互

The use of TortoiseSVN little turtle

Live Classroom System 08 Supplement - Tencent Cloud Object Storage and Course Classification Management

快消品行业经销商协同系统:实现经销商可视化管理,提高沟通执行效率

shell (text printing tool awk)

直播课堂系统09--腾讯云点播管理模块(一)

shell programming without interaction

ACM解题笔记——HDU 1401 Solitaire(DBFS)

shell脚本循环语句for、while语句

Uniapp编译后小程序的代码反编译一些思路
随机推荐
这些不可不知的JVM知识,我都用思维导图整理好了
为什么一般公司面试结束后会说「回去等消息」,而不是直接告诉面试者结果?
Black cat takes you to learn Makefile Part 12: Summary of common Makefile problems
DELETE:删除操作语法&使用例——《mysql 从入门到内卷再到入土》
ACM解题笔记——HDU 1401 Solitaire(DBFS)
ArcPy读取Excel时序数据、批量反距离加权IDW插值与掩膜
B. Trouble Sort
LeetCode-402-移掉K位数字
Web Reverse Lilac Garden
Live Classroom System 08-Tencent Cloud Object Storage and Course Classification Management
Bedtime story | made a Bitmap and AST length system configuration
B. Codeforces Subsequences
shell programming without interaction
ACM模板笔记:八数码问题——使用BFS+康托展开打表解决
Live Classroom System 09--Tencent Cloud VOD Management Module (1)
财务年报怎样翻译,为什么要选择专业翻译公司?
2022.8.8好题选讲(数论场)
[Maui official version] Create a cross-platform Maui program, as well as the implementation and demonstration of dependency injection and MVVM two-way binding
labelme-屏蔽拖拽的事件
These must-know JVM knowledge, I have sorted it out with a mind map