dongqiang2069 2013-08-17 13:39
浏览 102
已采纳

如何在终端中使用inotify-tools获取递归目录路径

I'm using inotify-tools where i want a notification of file which has been created in recursive directories

Till here i'm succesfull

Now i want to get directory path where a file is been created/dumped in the recursive folders

for e.g abc.txt file is dumped in data/test folder

i want the path to be data/test/abc.txt

Below is the code im using in .sh file

inotifywait -m -r --format '%f' -e modify -e move -e create -e delete /var/www/cloud/data | while read LINE; 
do 
    php /var/www/cloud/scannner/watcher.php; 
done

Kindly please help me to get the path of a dumped file in recursive directories

Cheers

  • 写回答

1条回答 默认 最新

  • douchuituo3032 2013-08-17 14:19
    关注

    Use the %w modifier:

    inotifywait -m -r --format '%w%f' .......
    

    To pass the output of inotifywait as an argument to a php script, which will read it for the argv variable you could do this:

    inotifywait -m -r --format '%w%f' ....... | while read -r line
    do 
        php script.php "$line"
    done
    

    Otherwise, if you want the php script to read the output of inotifywait from the standard input, then you can just pipe to your script:

    inotifywait -m -r --format '%w%f' ....... | php script.php
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题