- 编写脚本/root/bin/systeminfo.sh,显示当前主机系统信 息,包括主机名,IPv4地址,操作系统版本,内核版本, CPU型号,内存大小,硬盘大小。
- 编写脚本/root/bin/backup.sh,可实现每日将/etc/目录 备份到/root/etcYYYY-mm-dd中
- 编写脚本/root/bin/disk.sh,显示当前硬盘分区中空间利用率最大的值
- 编写脚本/root/bin/links.sh,显示正连接本主机的每个远 程主机的IPv4地址和连接数,并按连接数从大到小排序
- 写一个脚本/root/bin/sumid.sh,计算/etc/passwd 文件中的第10个用户和第20用户ID之和
- 写一个脚本/root/bin/sumspace.sh,传递两个文件 路径作为参数给脚本,计算这两个文件中所有空白行之和
- 写一个脚本/root/bin/sumfile.sh,统计/etc, /var, /usr目录中共有多少个一级子目录和文件
- 写一个脚本/root/bin/argsnum.sh,接受一个文件路径作 为参数;如果参数个数小于1,则提示用户“至少应该给一个 参数”,并立即退出;如果参则显数个数不小于1,示第一个 参数所指向
shell脚本案例
最新推荐文章于 2024-04-19 15:26:19 发布
本文介绍了多个实用的Shell脚本案例,包括显示系统信息、文件备份、磁盘空间管理、网络连接检查、权限判断、用户管理、数学运算、文件操作等,覆盖了日常系统管理和维护的多个方面。
摘要由CSDN通过智能技术生成