我有以下脚本,它使用inotify来检测文件夹内的更改。如您所见,我将整个路径加上变量VAR下的潜在新文件的名称。 VAR将会像我在评论中的字符串一样。当我从另一个文件夹粘贴东西时,一切正常,但是当通过rsync将文件传输到那里时,那么VAR就像这样/ is/the/path/.filename.log.JgHKzP这意味着在文件名和.XXXXXX添加在它的后面。例如,我得到这个通过rsync通过inotify识别错误的文件名
/home/user/CarMonitor/logs/gps/.gps-2015-11-3-18-7-41.log.QvPgm9
我的意思是我可以做一些字符串更改,使其正确,但为什么会发生这种情况?提前致谢。
#!/bin/bash
inotifywait -r -m /home/user/CarMonitor/logs -e create | #Wait till new files arrive (Flags: -m for 'monitor', -e for 'event')
while read path action file; do
#echo "The file '$file' appeared in directory '$path' via '$action'"
VAR=$path$file
#VAR="asddas/sd/f/sda/gps/sdfsdfsdfsd.log"
echo $VAR
//Do stuff
done
谢谢Kenster为您详细解答。正是我需要的。 –