#! /bin/sh # undot_paths : lines path |> lines path # Remove all dots (. and ..) from input paths. set -euf sed ' :0 s://\+:/:g s:/\.\(/\|$\):\1:g s:/[^/]\+/\.\.\(/\|$\):\1:g s:^/\(\.\./\)\+:/: t0 s:^$:/: '