3

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?

Barmar
  • 741,623
  • 53
  • 500
  • 612
Arringar1
  • 395
  • 4
  • 9
  • 21

1 Answers1

2

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
Barmar
  • 741,623
  • 53
  • 500
  • 612