Just in case there isn't a built-in way to do this, you could use a simple replacement for sort:
#!/usr/bin/env python
import sys
for i in sorted(sys.stdin):
sys.stdout.write(i)
Save it, for example, at /bin/pysort and make it executable (sudo cp whatever.py /bin/pysort and sudo chmod a+x /bin/pysort), and run it as ls | pysort:
As a one-off command you can do this:
LC_COLLATE=C ls
Or you can add
export LC_COLLATE="C"
to your .bashrc to make it permanent (may have unexpected results sorting elsewhere).More information on Ubuntu forums.
Just in case there isn't a built-in way to do this, you could use a simple replacement for
sort
:Save it, for example, at
/bin/pysort
and make it executable (sudo cp whatever.py /bin/pysort
andsudo chmod a+x /bin/pysort
), and run it asls | pysort
:would
ls | sort
not do exactly what you need?