侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

Linux—计算/etc/目录所有*.conf配置文件所占总空间大小

2023-04-25 星期二 / 0 评论 / 0 点赞 / 72 阅读 / 2677 字

计算/etc/目录中所有*.conf配置文件所占用的总空间大小1.用vi创建一个名为confsize.sh脚本,截图如下:内容如下:#!/bin/bashsizenums=$(ls -l $(find

.

计算/etc/目录中所有*.conf配置文件所占用的总空间大小

1.用vi创建一个名为confsize.sh脚本,截图如下:

内容如下:

#!/bin/bash

sizenums=$(ls -l $(find /etc/ -type f -a -name *.conf) | awk '{print $5}')

total=0

for i in $sizenums

do

total=$(expr $total + $i)

done

echo "total size of conf files: $total bytes."

 

其中:

ls -l $(find /etc/ -type f -a -name *.conf) 用于统计。conf文件的信息

ls -l $(find /etc/ -type f -a -name *.conf) | awk '{print $5}' 列出每个文件所对应的大小

 

2.赋予confsize.shx权限,并执行脚本验证效果。


 

检查以bash为登录shell在/opt目录中的文件数量并列出具体的数值及对应的用户账户

1、用vi创建一个名为shell.sh脚本,截图如下:

内容如下:

#!/bin/bash

DIR="/opt/"

users=$(grep "bash$" /etc/passwd | awk -F: '{print $1}')

for username in $users

do

num=$(find $DIR -user $username | wc -l)

echo "$username have $num files."

done

2、在/opt目录下临时先创建一些测试文件,以备方便验证效果:

3、给脚本shell.sh增加x权限

4、执行脚本,查看执行后的信息

欢迎关注微信公众号:小温研习社

.

广告 广告

评论区