I want to use
find and sort the response. I assumed that a simple pipe
find ... | sort would do it, but the sorting behaviour is weird. For simplicity a simple text file:
asdf/2/22 asdf/2/01 asdf/20/0 asdf/20/1
My expected result would be
asdf/2/01 asdf/2/22 asdf/20/0 asdf/20/1
asdf/20/0 asdf/20/1 asdf/2/01 asdf/2/22
It doesn't matter as I only want the directories to appear in groups.
Here are my attempts:
[root@linux6 ~]# cat sort_test | sort asdf/20/0 asdf/2/01 asdf/20/1 asdf/2/22 [root@linux6 ~]# cat sort_test | sort -d asdf/20/0 asdf/2/01 asdf/20/1 asdf/2/22 [root@linux6 ~]# cat sort_test | tr "/" "X" | sort asdfX20X0 asdfX20X1 asdfX2X01 asdfX2X22 [root@linux6 ~]# cat sort_test | tr "/" "_" | sort asdf_20_0 asdf_2_01 asdf_20_1 asdf_2_22 [root@linux6 ~]#
Note that it only works with "X". Any non-alphanumeric character seems to break the output. I also tried the
-t '/' options with no change in the output.
sort seems to remove the non-alphanumeric characters first and then sort the line even though I didn't mention
-d. There is no
alias for sort.
[root@linux6 ~]# which sort /usr/bin/sort [root@linux6 ~]# uname -a Linux i-epg-appl1 3.10.0-229.14.1.el7.x86_64 #1 SMP Tue Sep 15 15:05:51 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux [root@linux6 ~]# sort --version sort (GNU coreutils) 8.22