/ Published in: Bash
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# Requires GNU find (for -print0). Since the find example starts in ".", I replace # the leading "./" of all results with the working directory PWD to get an absolute # path for each result. Alternatively use 'find "$PWD"' instead of 'find .' unset a declare -a a while read -d '' -r; do a+=("$PWD/${REPLY#./}") done < <(find . -name \*.txt -print0) # Verify printf ">%s<\n" "${a[@]}" # Same, on one line, without the, using "$PWD" and without GNU find: unset a; declare -a a; while read -d '' -r; do a+=("$REPLY"); done < <(find "$PWD" -name \*.txt -exec printf "%s\0" {} \;)