当前位置:网站首页>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
边栏推荐
- Oracle 19C OCP 1z0-083 question bank (7-12)
- node的js文件引入
- P1825 [USACO11OPEN]Corn Maze S
- OA项目之我的会议(会议排座&送审)
- 《Datawhale熊猫书》出版了!
- Learning notes of automatic control principle --- linear discrete system
- Oracle 19C OCP 1z0-082 certification examination question bank (42-50)
- Self review ideas of probability theory
- Neo eco technology monthly | help developers play smart contracts
- The idea shortcut key ALT realizes the whole column operation
猜你喜欢
keepalived双机热备
Database operation topic 1
Cadence(十)走线技巧与注意事项
JDBC数据库连接池(Druid技术)
Media at home and abroad publicize that we should strictly grasp the content
Study notes of automatic control principle -- correction and synthesis of automatic control system
[database] gbase 8A MPP cluster v95 installation and uninstall
My meeting of OA project (meeting seating & submission for approval)
机器学习中的概率模型
合工大苍穹战队视觉组培训Day6——传统视觉,图像处理
随机推荐
Web概述和B/S架构
Kept dual machine hot standby
Pan micro e-cology8 foreground SQL injection POC
The effective condition of MySQL joint index and the invalid condition of index
Set of pl/sql
【加密周报】加密市场有所回温?寒冬仍未解冻 盘点上周加密市场发生的重大事件
[freeswitch development practice] use SIP client Yate to connect freeswitch for VoIP calls
Foundry tutorial: writing scalable smart contracts in various ways (Part 1)
Oracle 19C OCP 1z0-083 question bank (7-12)
正则表达式:判断是否符合USD格式
Day06 homework -- skill question 1
[recommended collection] MySQL 30000 word essence summary - query and transaction (III)
Deploy prometheus+grafana monitoring platform
Learn more about the difference between B-tree and b+tree
03 exception handling, state keeping, request hook -- 04 large project structure and blueprint
CSDN TOP1“一个处女座的程序猿“如何通过写作成为百万粉丝博主?
at、crontab
Oracle 19C OCP 1z0-082 certification examination question bank (24-29)
数据库操作技能7
Learning notes of automatic control principle --- linear discrete system