当前位置:网站首页>Rocky基础练习题-shell脚本2
Rocky基础练习题-shell脚本2
2022-07-26 08:48:00 【51CTO】
写一个脚本,完成如下功能:
(1) 列出当前系统识别到的所有磁盘设备 (2) 如磁盘数量为1,则显示其空间使用信息,否则,则显示最后一个磁盘上的空间使用信息
#!/bin/bash
disk=/dev/`lsblk |egrep -o '^sd[a-z]' |tail -1`
disksum=`fdisk -l $disk|sed -rn 's/.* ([0-9]+) sectors/\1/p'`
parsum=`fdisk -l $disk |tail -1| awk '{print $3}'`
sumG=`fdisk -l $disk |sed -rn "s#^Disk /dev.* ([0-9]+) G.*#\1#p"`
used=`echo "(${disksum}-${parsum})*512/1024/1024/1024" |bc`
echo "您的磁盘${disk}共计${sumG}GB,使用了${used}GB"
[[email protected] ~]# ./blk.sh
您的磁盘/dev/sde共计20GB,使用了16GB
边栏推荐
- day06 作业--技能题1
- tcp 解决short write问题
- TypeScript版Snowflake主键生成器
- The lessons of 2000. Web3 = the third industrial revolution?
- [encryption weekly] has the encryption market recovered? The cold winter still hasn't thawed out. Take stock of the major events that occurred in the encryption market last week
- Sklearn machine learning foundation (linear regression, under fitting, over fitting, ridge regression, model loading and saving)
- 12306 ticket system crawling - 1. Saving and reading of city code data
- Which financial product has the highest yield in 2022?
- Introduction to AWD attack and defense competition
- 【加密周报】加密市场有所回温?寒冬仍未解冻 盘点上周加密市场发生的重大事件
猜你喜欢

sklearn 机器学习基础(线性回归、欠拟合、过拟合、岭回归、模型加载保存)

What are the contents of Oracle OCP and MySQL OCP certification exams?

Database operation skills 6

JDBC数据库连接池(Druid技术)

Review notes of Microcomputer Principles -- zoufengxing

【加密周报】加密市场有所回温?寒冬仍未解冻 盘点上周加密市场发生的重大事件

【搜索专题】看完必会的搜索问题之洪水覆盖

Web3 Games: current situation and future

Study notes of automatic control principle -- dynamic model of feedback control system

Study notes of automatic control principle --- stability analysis of control system
随机推荐
Day06 homework - skill question 6
12306 ticket system crawling - 1. Saving and reading of city code data
有限元学习知识点备案
day06 作业--技能题2
Okaleido launched the fusion mining mode, which is the only way for Oka to verify the current output
day06 作业--技能题6
Solve the problem of C # calling form controls across threads
Web overview and b/s architecture
node-v下载与应用、ES6模块导入与导出
JDBC database connection pool (Druid Technology)
Database operation topic 2
Oracle 19C OCP certification examination software list
General file upload vulnerability getshell of a digital campus system (penetration test -0day)
Mysql database connection / query index and other common syntax
Xtrabackup appears' flush no '_ WRITE_ TO_ BINLOG TABLES‘: 1205 (HY000) Lock wait timeout exceeded;
Mutual transformation of array structure and tree structure
[untitled]
Foundry教程:使用多种方式编写可升级的智能合约(上)
CIS 2020 - alternative skills against cloud WAF (pyn3rd)
【数据库 】GBase 8a MPP Cluster V95 安装和卸载