我试过这个方法,但它不起作用。。。
inotifywait -mr -e create /opt/freeswitch/storage/ 2>&-| sed 's/ CREATE //g' |
while read file; do
chown apache.apache $file
done
来自命令行
inotifywait -mr -e create /opt/freeswitch/storage/ 2>&-| sed 's/ CREATE //g'
提供了我需要的确切输出和文件的完整路径,但当我试图将sed输出到文件或将其输出管道到其他文件时,它就停止了工作。
有人能在这里给我指正确的方向吗?
默认情况下,sed
在写入管道时缓冲其输出。使用-u
选项解除缓冲。
inotifywait -mr -e create /opt/freeswitch/storage/ 2>&-| sed -u 's/ CREATE //g' |
while read file; do
chown apache.apache $file
done