inotifywaitを使用して特定の拡張子を持つファイルを除外する

inotifywaitを使用して特定の拡張子を持つファイルを除外する

着信暗号化されたファイルを表示していますが、2つの拡張子がありますtestfile<date>.dat.pgp。たとえば。

問題は、ファイルが復号化されると、testfile<date>.datモニタディレクトリに新しいfile()が作成され、モニタプロセスの別の望ましくない実行がトリガされることです。

testfile<date>.dat除外する方法は何ですかtestfile<date>.dat.pgp

これは私のコードです。

inotifywait -m -e create --format '%w%f'  "${MONITORDIR}"  |  while read  NEWFILE
do

    #decrypts testfile.dat.pgp
    # new file "testfile<date>.dat" is created in the $MONITOR_DIR which triggers
    # the inotifywait process to run again.

done

ベストアンサー1

次に、電話を転送してください。grep

inotifywait -m -e create --format '%w%f' "${MONITORDIR}" |\
grep '.dat.pgp$' --line-buffered | while read  NEWFILE 
   do

   #decrypts testfile.dat.pgp
   # new file "testfile.dat" is created in the $MONITOR_DIR which triggers
   # the inotifywait process to run again.

   done

inotifywaitのある拡張プログラムのみを視聴します.dat.pgp

おすすめ記事