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 contain the NULL (\0) character i thought this would make a great delimiter for the results being piped to sort
.
so this is what i would expect to work as described:
find ./ -maxdepth 1 -type d -iname 'xyz?' -print0 | sort -t $'\0'
but sadly i got the compaint sort: empty tab
looking around for a explanation a came across a question leading to a similar result that the op described as working fine (see lucas comment of apr 26th). in my case (using GNU sort v 7.4) this is seems different.
i also checked the output of find by piping into od -c
but this only shows that the resulting folders are separated by NULL as expected.
has anybody here come across a similar scenario and possibly found a solution or explanation why \0 seem to be an impossible delimiter for sort?
looking forward to you answers...
edit: note that the find-command is used as an example here, a simpler way to test/illustrate this could be echo "g\0u\0b\0k" | sort -t $'\0'