Grimoire-
Command
.es

GNU+Linux command memo

Wait for a file to appear with inotifywait

Attendre l’apparition d’un fichier. Utile pour bloquer l’exécution d’un script jusqu’à l’arrivée du fichier créé en parallèle.

$ inotifywait -e close_write --include 'file_name' file/parent_dir/

inotifywait waits for a file event. Here we wait for the close_write event, so the closing of a file opened in write mode (but not necessarily written in…). Then we filter the events to consider only the one matching the --include regex and we watch in the file/parent_dir/ folder (and subfolders).

Usefull to stop a script execution until the file arrives.