summaryrefslogtreecommitdiff
path: root/home/xyz/.local/bin/dirnameall
diff options
context:
space:
mode:
Diffstat (limited to 'home/xyz/.local/bin/dirnameall')
-rwxr-xr-xhome/xyz/.local/bin/dirnameall21
1 files changed, 21 insertions, 0 deletions
diff --git a/home/xyz/.local/bin/dirnameall b/home/xyz/.local/bin/dirnameall
new file mode 100755
index 00000000..6bd67fd3
--- /dev/null
+++ b/home/xyz/.local/bin/dirnameall
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+while read -r line; do
+ if [ -n "$paths" ]; then
+ paths="$paths
+$line"
+ else
+ paths="$line"
+ fi
+done
+dirs="$(echo "$paths" | tr '\n' '\0' | xargs -0 dirname | sort | uniq)"
+
+paths="$paths
+$dirs"
+while [ "$(echo "$dirs" | wc -l)" -ne 1 ]; do
+ dirs="$(echo "$dirs" | tr '\n' '\0' | xargs -0 dirname | sort | uniq)"
+ paths="$paths
+$dirs"
+done
+
+echo "$paths" | sort | uniq | grep -v '^\.$'