#!/bin/bash perm() { # frei nach http://stackoverflow.com/questions/3846123/generating-permutations-using-bash local items="$1" local out="$2" local i [[ "$items" == "" ]] && permutation[j++]="$out*" && return for (( i=0; i<${#items}; i++ )) ; do perm "${items:i+1}" "$out*${items:0:i+1}" done } add_find(){ while read -rd '' do erg[k++]="$REPLY" done < <(find . -type f -iwholename "$1" -print0 2>/dev/null) } sort_depth(){ arr=( "${erg[@]}" ) l=0 for ((i=1; i<=$maxdepth; i++)) do for ((j=0; j<$k; j++)) do count="${arr[j]//[^\/]/}" [[ "${#count}" == "$i" ]] && erg[l++]="${arr[j]}" done done } t1="$(date +%s)" string="$1" length="$(echo $string | wc -m)" k=0 maxdepth=15 perm "$string" starcount=1 while [ $((starcount-1)) -lt "$length" ] && [ $k -lt 1 ] do for i in "${permutation[@]}" do count="${i//[^\*]/}" [[ "${#count}" == "$starcount" ]] && add_find "$i" && printf "%b" "$i\r" done t2="$(date +%s)" [[ $((t2-t1)) -gt 30 ]] && break ((starcount++)) done sort_depth t2="$(date +%s)" printf "%${length}s\r" echo "Zeit: $((t2-t1)) s" for i in "${erg[@]}" do echo "$i" done