当前位置:网站首页>Rocky basic exercise -shell script 2
Rocky basic exercise -shell script 2
2022-07-26 09:55:00 【51CTO】
Write a script , Complete the following functions :
(1) List all disk devices recognized by the current system (2) If the number of disks is 1, The space usage information is displayed , otherwise , The space usage information on the last disk is displayed
#!/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 " Your disk ${disk} total ${sumG}GB, Used ${used}GB"
[[email protected] ~]# ./blk.sh
Your disk /dev/sde total 20GB, Used 16GB
边栏推荐
- Registration module use case writing
- El table implements adding / deleting rows, and a parameter changes accordingly
- Leetcode 504. Hex number
- Spolicy request case
- Applet record
- Fuzzy PID control of motor speed
- 莫队学习总结(二)
- (2) Hand eye calibration of face scanner and manipulator (eye out of hand: nine point calibration)
- Fiddler packet capturing tool for mobile packet capturing
- 万字详解“用知识图谱驱动企业业绩增长”
猜你喜欢
QT handy notes (III) use qtcharts to draw a line chart in VS
服务发现原理分析与源码解读
protobuf的基本用法
El table implements adding / deleting rows, and a parameter changes accordingly
一种分布式深度学习编程新范式:Global Tensor
PMM (percona monitoring and management) installation record
Alibaba cloud technology expert haochendong: cloud observability - problem discovery and positioning practice
2019 ICPC Asia Yinchuan regional (water problem solution)
Gauss elimination solves the inverse of matrix (Gauss)
面试突击68:为什么 TCP 需要 3 次握手?
随机推荐
AR model in MATLAB for short-term traffic flow prediction
网易云UI模仿-->侧边栏
JS one line code to obtain the maximum and minimum values of the array
面试突击68:为什么 TCP 需要 3 次握手?
SSG框架Gatsby访问数据库,并显示到页面上
Wechat applet learning notes 2
图解用户登录验证流程,写得太好了!
R language ggplot2 visualization: align the legend title to the middle of the legend box in ggplot2 (default left alignment, align legend title to middle of legend)
Draw arrows with openlayer
【信息系统项目管理师】初见高项系列精华汇总
Applet record
Flutter event distribution
B站这个视频我是跪着看完的
(1) Hand eye calibration of face scanner and manipulator (eye on hand)
在同一conda环境下先装Pytroch后装TensorFlow
The whole process of server environment configuration
Study notes of the second week of sophomore year
El table implements adding / deleting rows, and a parameter changes accordingly
Search module use case writing
【Datawhale】【机器学习】糖尿病遗传风险检测挑战赛