Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am creating image sprites and have neatly named around 100 files. I am using the following to generate an image sprite from individual images:

convert $(ls -w 1000) +append sprite.png

I have just noticed that Nautilus 3.4.2 sorts by name differently from ls.

Is there a way to get ls to use the same ordering as Nautilus (and not the other way around)?

Example

Nautilus order:

  • cloudy_with_heavy_rain.png
  • cloudy_with_heavy_rain_night.png

ls order:

  • cloudy_with_heavy_rain_night.png
  • cloudy_with_heavy_rain.png
share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

Well this drove me mad for five minutes. Change your statement to:

convert $(LC_COLLATE="C" ls -w 1000) +append sprite.png

For some reason Nautilus doesn't follow the system-wide locale settings so sorts are out of sync. By faking back to the standard, sorts unify.


My test harness:

$ mkdir test && cd test
$ touch cloudy_with_heavy_rain{,_night}.png

$ ls -l
total 0
-rw-rw-r-- 1 oli oli 0 Apr 13 00:32 cloudy_with_heavy_rain_night.png
-rw-rw-r-- 1 oli oli 0 Apr 13 00:32 cloudy_with_heavy_rain.png

$ LC_COLLATE="C" ls -l
total 0
-rw-rw-r-- 1 oli oli 0 Apr 13 00:32 cloudy_with_heavy_rain.png
-rw-rw-r-- 1 oli oli 0 Apr 13 00:32 cloudy_with_heavy_rain_night.png
share|improve this answer
    
Excellent. That sorts it :) –  Gibbs Apr 12 '13 at 23:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.