summaryrefslogtreecommitdiff
path: root/sh/dirnameall
blob: befd3478409a6c4a32c59a3055cbf1f8142468d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh

while read -r line; do
	if [ "$paths" ]; then
		paths="$paths
$line"
	else
		paths="$line"
	fi
done

dirs="$paths"
while [ "$dirs" != '.' ]; do
	[ "$dirs" ] && paths="$paths
$dirs"
	dirs="$(echo "$dirs" | tr '\n' '\0' | xargs -0 dirname | awk '!a[$0]++')"
done

echo "$paths" | awk '!a[$0]++' | grep -v '^\.$'