stockholm/bin/undot-paths
2015-05-21 01:56:08 +02:00

15 lines
222 B
Bash
Executable File

#! /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:^$:/:
'