Take for example, a simple little directory listing:
jake$ cat sortit.txt
prodappl
prodappl/abm
prodappl/APPLSYS.env.tmp
prodappl/abm/11.5.0/admin
prodappl/APPSORA.env
prodappl/PROD.env
prodappl/abm/11.5.0
prodappl/abm/11.5.0/admin/driver
prodappl/APPLSYS.env
prodappl/abm/11.5.0/admin/driver/abmcon.drv
On Linux, I sort it:
jake$ cat sortit.txt | sort
prodappl
prodappl/abm
prodappl/abm/11.5.0
prodappl/abm/11.5.0/admin
prodappl/abm/11.5.0/admin/driver
prodappl/abm/11.5.0/admin/driver/abmcon.drv
prodappl/APPLSYS.env
prodappl/APPLSYS.env.tmp
prodappl/APPSORA.env
prodappl/PROD.env
On Solaris, same command:
woody# cat sortit.txt | sort
prodappl
prodappl/APPLSYS.env
prodappl/APPLSYS.env.tmp
prodappl/APPSORA.env
prodappl/PROD.env
prodappl/abm
prodappl/abm/11.5.0
prodappl/abm/11.5.0/admin
prodappl/abm/11.5.0/admin/driver
prodappl/abm/11.5.0/admin/driver/abmcon.drv
Hmm. I did a "man sort" and found my answer was to force a sort order using the -f flag.
2 comments:
Likely your locale settings. Check your environment.
Get this - on Red Hat Enterprise Linux:
Start off with the default LANG setting:
> echo $LANG
en_US.UTF-8
> sort < sortit.txt
prodappl
prodappl/abm
prodappl/abm/11.5.0
prodappl/abm/11.5.0/admin
prodappl/abm/11.5.0/admin/driver
prodappl/abm/11.5.0/admin/driver/abmcon.drv
prodappl/APPLSYS.env
prodappl/APPLSYS.env.tmp
prodappl/APPSORA.env
prodappl/PROD.env
Now watch this:
> unsetenv LANG
> sort < sortit.txt
prodappl
prodappl/APPLSYS.env
prodappl/APPLSYS.env.tmp
prodappl/APPSORA.env
prodappl/PROD.env
prodappl/abm
prodappl/abm/11.5.0
prodappl/abm/11.5.0/admin
prodappl/abm/11.5.0/admin/driver
prodappl/abm/11.5.0/admin/driver/abmcon.drv
Post a Comment