How to use NULL (\0) as the delimiter in GNU sort

前端 未结 3 818
执念已碎
执念已碎 2021-02-19 04:45

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 conta

3条回答
  •  伪装坚强ぢ
    2021-02-19 05:15

    Use the -z option to sort zero-terminated data sets:

    find ./ -maxdepth 1 -type d -iname 'xyz?' -print0 | sort -z | tr '\0' '\n'
    

提交回复
热议问题