Question

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?

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top