Ubuntu 16.04
即使 for 的输出client in */; do
不会产生斜杠,如果我在循环内对文件执行时间测试时回显变量 $client ,也会出现斜杠。
cd "$wDir"
for client in */; do
cd "$wDir"/"$client";
#-- check to see if any .csv files exists
if ls *.csv &>/dev/null; then
for csvfile in *.csv; do
if test $(find "$csvfile" -mmin +2880); then
echo "$client has files older than 2 days ..." >> "staleFtpAccts"
fi
done
fi
done
当我执行脚本时,在 $client 变量之后放置一个 / ,如下所示:
root@me /home/frank # bash script.sh
Start ...
000029_000020/ has files older than 2 days ...
#--
Finished ...
Start ...
000033_000040/ has files older than 2 days ...
#--
Finished ...
Start ...
000033_000041/ has files older than 2 days ...
#--
Finished ...
Start ...
000033_000042/ has files older than 2 days ...
#--
Finished ...
Start ...
000033_000043/ has files older than 2 days ...
#--
Finished ...
这是我追求的结果...
root@me /home/frank # bash script.sh
Start ...
000029_000020 has files older than 2 days ...
#--
Finished ...
Start ...
000033_000040 has files older than 2 days ...
#--
Finished ...
Start ...
000033_000041 has files older than 2 days ...
#--
Finished ...
Start ...
000033_000042 has files older than 2 days ...
#--
Finished ...
Start ...
000033_000043 has files older than 2 days ...
#--
Finished ...
试试这个posix 参数扩展:
所以