#! /bin/sh # make-parent-dirs : lines path |> lines directory # List all parent directories of a path. set -euf set -- "$(sed -n 's|/[^/]*$||p' | grep . | sort | uniq)" if echo "$1" | grep -q .; then echo "$1" echo "$1" | make-parent-dirs fi