i am looking for a way to sort the results of find
returning a number of directories correctly for further processing in a bash script. since filenames can\'t conta
For further processing in a Bash script see, for example:
Capturing output of find . -print0 into a bash array
# cf. http://mywiki.wooledge.org/BashFAQ/020
unset a i
while IFS='' read -r -d $'\0' dir; do
a[i++]="$dir" # or however you want to process each directory
done < <(find ./ -maxdepth 1 -type d -iname 'xyz?' -print0 | LC_ALL=C sort -z)
printf '%s\n' "${#a[@]}"
printf '%s\n' "${a[@]}"
# btw, you may use printf to add zero bytes
printf '%c\000' g u b k | sort -z | tr '\0' ' '
printf '%s\000' g1 u2 b3 k4 | sort -z | tr '\0' ' '