【发布时间】:2016-08-08 17:06:10
【问题描述】:
如何循环遍历每个用户的 /home 目录并删除文件夹?这将是一个常见的称为/home/$user/.quarentine。
【问题讨论】:
如何循环遍历每个用户的 /home 目录并删除文件夹?这将是一个常见的称为/home/$user/.quarentine。
【问题讨论】:
在一行中:
for user in $(ls /home); do rm -Rf /home/${user}/.quarentine; done
【讨论】:
for user in /home/*。 It is not good to parse the output of ls
像这样:
#!/bin/bash
#Get the list of users
USERS=`ls -l /home|grep "^d"|awk '{print $NF}'`
#Loop for each user and delete the files
for i in $USERS
do
rm -rf /home/$i/.quarentine
done
【讨论】: