GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu)
Idea is to set a variable to a NUL delimited data set. Here
This, however, result in:
warning: command substitution: ignored null byte in input
samples="$(find . -type d -iregex './sample[0-9][0-9]' -printf "%f\0" | sort -z)"
Thought I could re-use this variable as I need to iterate the same values multiple times:
while IFS= read -rd '' sample; do echo $sample done<<< "$samples"
I could use
\0 in the find command in this exact case, but would like to know how, if possible, to do it with NUL delimiter generally speaking.
Optionally I could do:
while IFS= read -rd '' sample; do echo $sample done< <(find . -type d -iregex './E[0-9][0-9]' -printf "%f\0" | sort -z)
but - as I need to loop it several times it makes for some very redundant code - and would have to run the find and sort command each time.
Convert the result into an array perhaps?
- Is this possible?
- Why can not NUL delimited data be used as is?