在这种情况下,我如何捕获inotifywait的输出,这让我抓狂。
这是我的代码:
while inotifywait -q -e create,delete --format '%T %:e "%f"' --timefmt '%d/%m/%y %H:%M' "$DIR"
do
echo -e "$line" >> /mnt/pidrive1/Digital_Signage/log/"$hostname"_sync.log
echo -e "Folder contents:" $file_number "files in total: " $folder_list >> /mnt/pidrive1/Digital_Signage/log/"$hostname"_sync.log
done发布于 2017-10-04 09:38:07
要实现你想要的目标,一个简单得多的方法是:
while inotifywait <whaveter> >> sync.log
do
# Nothing
done如果您需要对输出进行额外的处理,您可以这样说:
while out=$(inotifywait <whaveter>)
do
# Stuff
# Just use $out normally
donehttps://stackoverflow.com/questions/46561474
复制相似问题