3 ms·
As I said, that hasn't been a problem for a long time: $ find . -type f ./foo bar ./--stupid-filename ./-annoying dir name!/--very annoying pat
by pdkl95 7y ago
As I said, that hasn't been a problem for a long time:
$ find . -type f
./foo bar
./--stupid-filename
./-annoying dir name!/--very annoying path...
$ echo "pid=$$"
pid=31281
$ while IFS= read -r -d '' file ; do
> echo "[pid=$$] do something with '${file}'"
> list[i++]="$file"
> done < <(find . -type f -print0)
[pid=31281] do something with './foo bar'
[pid=31281] do something with './--stupid-filename'
[pid=31281] do something with './-annoying dir name!/--very annoying path...'
$ declare -p list
declare -a list='([0]="./foo bar" [1]="./--stupid-filename" \
[2]="./-annoying dir name!/--very annoying path..." [3]="./iter.sh")'
Using the character literal $'\0' also works as the delimiter, but Bash doesn't support sending null bytes in args. In bash, $'\0' is the empty string:
$ x=$'\0'
$ declare -p x
declare -- x=""