Find the answer to your Linux question:
Results 1 to 2 of 2
Hi all- I have several files in directory foo that are created in numerical order... /foo/bar1.txt /foo/bar2.txt ... /foo/bar100.txt however, ls /foo outputs: bar100.txt bar10.txt bar11.txt bar12.txt ... bar19.txt bar1.txt ...
  1. #1
    Just Joined!
    Join Date
    Nov 2005
    Location
    USA
    Posts
    40

    ls & sorting filenames

    Hi all-

    I have several files in directory foo that are created in numerical order...

    /foo/bar1.txt
    /foo/bar2.txt
    ...
    /foo/bar100.txt

    however, ls /foo outputs:
    bar100.txt
    bar10.txt
    bar11.txt
    bar12.txt
    ...
    bar19.txt
    bar1.txt
    bar20.txt
    bar21.txt
    ...
    bar2.txt
    bar30.txt

    ...so how do I get ls /foo to show:
    bar1.txt
    bar2.txt
    ...
    bar10.txt
    bar11.txt
    ...

    I've tried various things with sort, but maybe I'm missing something...any ideas would be appreciated!

  2. #2
    Banned jan1024188's Avatar
    Join Date
    Jul 2006
    Location
    EU, SLOVENIA
    Posts
    1,549
    try
    Code:
    sort -n

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...