summaryrefslogtreecommitdiff
path: root/home/xyz/.local/bin/dirnameall
diff options
context:
space:
mode:
authorxyz <gky44px1999@gmail.com>2021-12-13 23:13:56 -0800
committerxyz <gky44px1999@gmail.com>2021-12-13 23:13:56 -0800
commitbd44868a4c6ca4794292124b9e63d1209f9a36c8 (patch)
treed45f8cfc0e519527d7ca837e685f8fa3d679d4ed /home/xyz/.local/bin/dirnameall
parentb5be445b1b0758442b1ea98a4d8347542e0fc9ec (diff)
gitmetap, consider dirname
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 '^\.$'