我正在寻找一个小的bash脚本,在启动时,查看任何新创建的文件的目录.如果出现新文件,我希望它的存在触发第二个脚本运行.
我看到这用于触发压缩最近的数字化视频,并将其添加到摄取的镜头日志中.
目前我的代码如下所示:
#!/bin/sh
##VIDSTAT is a global variable coming from a parent script.
##proj is the ingestion directory coming from a parent script
proj=$1
dir="/home/$USER/data/movies/$proj"
dirlist=$(ls $dir)
while { $VIDSTAT -eq 1 }:
do
for mov in $dirlist
do
if [ "$(( $(date +"%s") - $(stat -c "%Y" $mov) ))" -lt "5" ]
then
~/bin/compressNlog.sh $mov
fi
done
done
Run Code Online (Sandbox Code Playgroud)
有没有更容易/更清洁/更少内存密集的方式来做到这一点?
编辑我将改变每个捕获会话的摄取目录.我已相应调整了代码