November 2013
Intermediate to advanced
224 pages
6h 9m
English
If you’ve used the UNIX command line for even five minutes, you’ve used ls. It shows you the names of files in a particular directory. Suppose you have a directory of images with numeric names. ls nicely formats it for you:
| | $ ls |
| | 10_image.jpg 2_image.jpg 5_image.jpg 8_image.jpg |
| | 11_image.jpg 3_image.jpg 6_image.jpg 9_image.jpg |
| | 1_image.jpg 4_image.jpg 7_image.jpg |
Suppose we want to see these files in numeric order. ls has no ability to do this; it sorts lexicographically, even when we use the invocation ls -1, which produces one file per line, in “sorted” order:[32]
| | $ ls -1 |
| | 10_image.jpg |
| | 11_image.jpg |
| | 1_image.jpg |
| | 2_image.jpg |
| | 3_image.jpg |
| | 4_image.jpg |
| | 5_image.jpg |
| | 6_image.jpg ... |
Read now
Unlock full access