0

在此处输入代码我想做的是一个脚本,它将收集在我的httpd.conf. 获取DoccumentRootServerName。然后du -s在文档根目录上执行 a 并将数据放入文件中。

现在我有这个命令:

grep -E "DocumentRoot|ServerName" /etc/httpd/conf/httpd.conf | grep -v "#" | awk '{print $2}'

它在单独的行上给我输出,但我不知道如何解析输出,所以我可以在新文件的同一行上du -s执行DocumentRoot然后获取。Size / DocumentRoot / ServerName

所需的输出应该是这样的:

size - Folder -  Servername

3436712 /etc/www/htdocs/domain www.domain.qc.ca
4

1 回答 1

0

尝试这样做:

grep -E "DocumentRoot|ServerName" /etc/httpd/conf/httpd.conf |
awk '!/#/{print $2}' |
xargs -n1 du -s 

或使用独特的管道:

grep -ioP '^\s*(?<!#)\s*(DocumentRoot|ServerName)\s+\K.*' /etc/httpd/conf/httpd.conf |
xargs -n1 du -s 
于 2013-03-12T15:49:31.163 回答