From dd78faaf40862bd1552ec36c41374b527f747284 Mon Sep 17 00:00:00 2001 From: Xiao Pan Date: Fri, 23 Feb 2024 03:08:52 -0800 Subject: Reorganize shell scripts into sh dir, consider in the future fsh will have different kinds of files --- sh/dirnameall | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 sh/dirnameall (limited to 'sh/dirnameall') diff --git a/sh/dirnameall b/sh/dirnameall new file mode 100755 index 0000000..befd347 --- /dev/null +++ b/sh/dirnameall @@ -0,0 +1,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 '^\.$' -- cgit v1.2.3-70-g09d2