#!/bin/bash ( echo -n "$1"/ ls -tc "$1" | head -n 1 inotifywait -q -m --exclude=xz -e CREATE --format %f "$1" ) | while read line; do trap "jobs -rp | xargs --no-run-if-empty kill" EXIT; jobs -rp | xargs --no-run-if-empty kill; tail -F "$line" & done