Sample Header Ad - 728x90

/bin/sort appears to ignore forward slashes in its input

2 votes
1 answer
318 views
I'm running Ubuntu 20.0.4. Consider these contents of the following file (suppose the file is named input) ... /zzzzz foo bar /hij zzz xyz abc /abc ijk lmnop qwer tyuiop abc def If I run /bin/sort input, I get the following output ... /abc abc def /hij zzz ijk lmnop qwer tyuiop xyz abc /zzzzz foo bar As you can see, the leading forward slash is totally ignored by the sort algorithm. There is nothing in the sort man page which says anything about forward slashes being treated in any kind of special way. But if I replace each of the forward slashes with the $ character, this behavior does not occur. For example, suppose that a file which is named newinput contains these values ... $zzzzz foo bar $hij zzz xyz abc $abc ijk lmnop qwer tyuiop abc def In other words, newinput is the same as input, except for the fact that / characters have been changed to $ characters. When I do /bin/sort newinput, I get these results ... $abc $hij zzz $zzzzz foo bar abc def ijk lmnop qwer tyuiop xyz abc As you can see, in this case, the $ is indeed treated as a normal, sortable character by /bin/sort. So, what's going on here? And how do I cause /bin/sort to pay attention to the / character? Thank you in advance for any ideas and suggestions. **UPDATE**: If I do this under Debian, the sort works properly, both with regard to / and $. So, I'm wondering if this behavior might be a "feature" of Ubuntu.
Asked by HippoMan (737 rep)
Sep 26, 2022, 12:36 AM
Last activity: Sep 26, 2022, 01:07 AM