当前位置:网站首页>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
边栏推荐
- Web overview and b/s architecture
- [freeswitch development practice] use SIP client Yate to connect freeswitch for VoIP calls
- Transfer guide printing system based on C language design
- After MySQL 8 OCP (1z0-908), hand in your homework
- 03 exception handling, state keeping, request hook -- 04 large project structure and blueprint
- 机器学习中的概率模型
- 03异常处理,状态保持,请求钩子---04大型项目结构与蓝图
- My meeting of OA project (query)
- Xshell batch send command to multiple sessions
- PXE principles and concepts
猜你喜欢

Xshell batch send command to multiple sessions

Learning notes of automatic control principle - Performance Analysis of continuous time system

第6天总结&数据库作业

pl/sql之动态sql与异常

Vision Group Training Day5 - machine learning, image recognition project

合工大苍穹战队视觉组培训Day5——机器学习,图像识别项目

Day06 operation -- addition, deletion, modification and query

Huffman transformation software based on C language

Set of pl/sql -2

Poor English, Oracle OCP or MySQL OCP exam can also get a high score of 80 points
随机推荐
idea快捷键 alt实现整列操作
第6天总结&数据库作业
Super potential public chain dfinity -- the best time for DFI developers to enter
node的js文件引入
Okaleido launched the fusion mining mode, which is the only way for Oka to verify the current output
Cadence (x) wiring skills and precautions
Excel find duplicate lines
Cve-2021-26295 Apache OFBiz deserialization Remote Code Execution Vulnerability recurrence
Xtrabackup appears' flush no '_ WRITE_ TO_ BINLOG TABLES‘: 1205 (HY000) Lock wait timeout exceeded;
Oracle 19C OCP 1z0-082 certification examination question bank (36-41)
P3743 kotori的设备
C Entry series (31) -- operator overloading
Mutual transformation of array structure and tree structure
Set of pl/sql
Typescript encryption tool passwordencoder
at、crontab
[recommended collection] summary of MySQL 30000 word essence - partitions, tables, databases and master-slave replication (V)
数据库操作技能7
Oracle 19C OCP 1z0-082 certification examination question bank (19-23)
P1825 [USACO11OPEN]Corn Maze S