Frage

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?

War es hilfreich?

Lösung

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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top