質問

I have tried this method but it does not work...

inotifywait -mr -e create /opt/freeswitch/storage/ 2>&-| sed 's/ CREATE //g' |
    while read file; do
    chown apache.apache $file
    done

From command line

inotifywait -mr -e create /opt/freeswitch/storage/ 2>&-| sed 's/ CREATE //g'

gives the exact output that I need with the full path of the file, but the moment I try to output sed to a file or pipe it's output into something else it stops working.

Can someone point me in the right direction here?

役に立ちましたか?

解決

By default, sed buffers its output when it's writing to a pipe. Use the -u option to unbuffer it.

inotifywait -mr -e create /opt/freeswitch/storage/ 2>&-| sed -u 's/ CREATE //g' |
    while read file; do
    chown apache.apache $file
    done
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top