尝试这个:
观察者.sh:
#!/bin/bash
if [ -z $1 ];
then
echo "You need to specify a dir as argument."
echo "Usage:"
echo "$0 <dir>"
exit 1
fi
while true;
do
for a in $(ls -1 $1/* 2>/dev/null);
do
otherscript $a && rm $a #calls otherscript with the file a as argument and removes it if otherscript returned something non-zero
done
sleep 2s
done
Run Code Online (Sandbox Code Playgroud)
不要忘记使其可执行
chmod +x ./watcher.sh
Run Code Online (Sandbox Code Playgroud)
调用它:
./watcher.sh <dirname>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15017 次 |
| 最近记录: |