Jérémy Scanvic

About

CV

Posts

A collection of somewhat useful code snippets #

streamdir

An almost-valid program chronologically streaming files from a directory tree using statx(2) and inotify(7)

Beware, it is not free of race conditions!

#!/usr/bin/env bash
[[ "${#@}" != "1" ]] && { echo "Usage: $0 <dir>" >&2; exit "1"; }

find "$1" \
	|xargs stat --format "%W %n" \
	|sort --numeric-sort --field-separator " " \
	|cut --delimiter=" " --fields "2"

inotifywait "$1" \
	--format "%w%f" \
	--quiet \
	--event "create" \
	--recursive \
	--monitor