|
General software and network General OS-independent software and network questions, X11, MTA, routing, etc. |
|
Thread Tools | Display Modes |
|
|||
ls sorting of numbered files
I don't really know where I should post this, but I remember Windows has the same behaviour, so I'm here.
Say I have some files named: 1 2 10 11 20 This is the order you expect, right? Code:
$ ls 1 10 11 2 20 |
|
||||
maybe try that:
Code:
% ls | sort -n | tr '\n' ' '
__________________
religions, worst damnation of mankind "If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”. vermaden's: links resources deviantart spreadbsd |
|
|||
thanks a lot
But why does ls behave like this? |
|
|||
but then, what about this:
Code:
$ ls | sort -n | tr '\n' ' ' a-1 a-10 a-2 a-20 $ |
|
||||
If you want that kind of sorting, then number your files properly:
Code:
% :> asd_01 % :> asd_02 % :> asd_10 % :> asd_11 % :> asd_20 % ls -1 asd_* asd_01 asd_02 asd_10 asd_11 asd_20 % ls asd_* asd_01 asd_02 asd_10 asd_11 asd_20
__________________
religions, worst damnation of mankind "If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”. vermaden's: links resources deviantart spreadbsd |
|
|||
this is what I actually do. I was only curious to know if there was a simple way around it if you get names with bad names without renaming them.
Thanks a lot. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Cleaning Portsnap files in /var/db/portsnap/files | bram85 | FreeBSD Ports and Packages | 2 | 5th October 2009 09:54 AM |
sorting special characters | gosha | Programming | 15 | 9th April 2009 02:29 AM |
finding files by uid | carpman | FreeBSD General | 3 | 5th February 2009 07:51 PM |
Encrypting Files | JMJ_coder | General software and network | 22 | 25th October 2008 07:49 AM |
Sorting Packages | JMJ_coder | NetBSD Package System (pkgsrc) | 3 | 20th May 2008 01:08 AM |