1

For whatever reason this command is quitting out after creating a single file in the folder. Not sure why when it is in monitor mode

$ inotifywait -m  /TDPROXY/NET_DISCONNECT/INCOMING/ -e create  | echo "new file"

Thanks

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
BostonMacOSX
  • 1,369
  • 2
  • 17
  • 38
  • 4
    `echo` doesn't read from standard input. When `echo` completes, it closes its end of the pipe, and `inotifywait` receives a SIGPIPE signal the next time it tries to write. – chepner Oct 18 '17 at 20:30

1 Answers1

2

I was having this problem and figured it out using chepner's comment. If you just run

$ inotifywait -m /TDPROXY/NET_DISCONNECT/INCOMING/ -e create

You'll see a stdout line printed everytime the event fires. So you just need a way to run echo whenever that happens.

I found a way from this question.

$ inotifywait -m /TDPROXY/NET_DISCONNECT/INCOMING/ -e create |
while read -r line; do echo "new file: ${line}"; done
ki9
  • 5,183
  • 5
  • 37
  • 48