I just wanted to point out something I recently learned that (I imagine) most Linux users have overlooked: version sort. Say we have some files like this:
Code:
$ touch pic.1.jpg pic.2.jpg pic.3.jpg pic.9.jpg pic.11.jpg pic.15.jpg pic.19.jpg pic.100.jpg pic.200.jpg
We know they will sort out of order, which is lame:
Code:
$ ls
pic.100.jpg pic.11.jpg pic.15.jpg pic.19.jpg pic.1.jpg pic.200.jpg pic.2.jpg pic.3.jpg pic.9.jpg
So some of us go to a lot of trouble to rename our files to 001, 002, 003, et cetera, or to make sure they are named that way in the first place. However,
ls has a
-v switch which makes that unnecessary, by figuring out the proper listing with an algorithm:
Code:
$ ls -v
pic.1.jpg pic.2.jpg pic.3.jpg pic.9.jpg pic.11.jpg pic.15.jpg pic.19.jpg pic.100.jpg pic.200.jpg
Anyway, if you didn't know about that switch, give me some rep, because I could really use some!
[Boring technical stuff you probably don't care about
:
Versions 2.1+ of glibc provide a
versionsort function which sorts directory entries in this way, defined in
<dirent.h>. This is based on the
strverscmp function which is defined in
<string.h>.]