当前位置:网站首页>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
边栏推荐
- Encapsulation of tabbarcontroller
- 解决ProxyError: Conda cannot proceed due to an error in your proxy configuration.
- Study notes of the first week of sophomore year
- 时间序列异常检测
- Solve the problem of storing cookies in IE7 & IE8
- [datawhale] [machine learning] Diabetes genetic risk detection challenge
- 2021 windows penetration of "Cyberspace Security" B module of Shandong secondary vocational group (analysis)
- 在.NET 6.0中配置WebHostBuilder
- Fuzzy PID control of motor speed
- Login module use case writing
猜你喜欢

Interview shock 68: why does TCP need three handshakes?

Due to fierce competition in the new market, China Mobile was forced to launch a restrictive ultra-low price 5g package

Server memory failure prediction can actually do this!

Solve NPM -v sudden failure and no response

The problem of accessing certsrv after configuring ADCs

一种分布式深度学习编程新范式:Global Tensor

服务器内存故障预测居然可以这样做!

Docker configuring MySQL Cluster

Matlab Simulink realizes fuzzy PID control of time-delay temperature control system of central air conditioning

R语言ggplot2可视化: 将图例标题(legend title)对齐到ggplot2中图例框的中间(默认左对齐、align legend title to middle of legend)
随机推荐
Solve NPM -v sudden failure and no response
JS one line code to obtain the maximum and minimum values of the array
2022年中科磐云——服务器内部信息获取 解析flag
解决ProxyError: Conda cannot proceed due to an error in your proxy configuration.
服务发现原理分析与源码解读
Uni app learning summary
在.NET 6.0中配置WebHostBuilder
Leetcode 504. 七进制数
Spolicy request case
面试突击68:为什么 TCP 需要 3 次握手?
Use of selectors
copyTo
Why does new public chain Aptos meet market expectations?
QT handy notes (II) edit control and float, qstring conversion
挡不住了,纯国产PC已就位,美国的软硬件体系垄断正式被破
Unstoppable, pure domestic PCs have been in place, and the monopoly of the U.S. software and hardware system has been officially broken
论文笔记(SESSION-BASED RECOMMENDATIONS WITHRECURRENT NEURAL NETWORKS)
Logical architecture of MySQL
M-ary number STR to n-ary number
regular expression