I have the following files
$ ls *.md | sort -n
1.pythonPrimer.md
10.mapsHashTablesAndSkipLists.md
11.searchTree.md
12.sortAndSelection.md
13.textProcessing.md
14.graphAlgorithms.md
15.memoryManagementAndBTrees.md
16.Appendix.md
2.Object Oriented Programming.md
3.algorithmsAnalysis.md
4.recursion.md
5.arrayBasedSequence.md
6.stack.md
7.linkedList.md
8.tree.md
9.priorityQueues.md
I want to sort them by the leading numbers in the order 1, 2, 3, 4....,
How could I get it done?
It works for me too. I think it will work for you, if you define a key
-k
and field separator-t
forsort
or with find
You should avoid using
ls
like this in command lines. Things can go wrong for several reasons. See this link (particularly the links in the comments by @Byte Commander).It works for me. Maybe you need to turn off locale?
Or, use the version sorting in
ls
: