I am doing this in OSX which uses bash but obviously, not all bash conventions are used so hopefully your suggestion is available to me 🙂
I have the following files
fun bar1.txt
Foo bar2.tXT
(that's an uppercase XT)fun fun.txt
What I was is to iterate through the file list in a sorted manner?
something like:
for i in (my-sorted-file-list); do
echo $i
done
Any ideas how this can be done? thanks a lot
Best Answer
Very simple:
This uses bash's file globbing. A sort is not necessary as bash already sorts pathname expansions.
From
man bash
:Â
Example result:
Note that the sort order is dependent upon
LC_COLLATE
(just like thesort
utility). If you want a case insensitive sort, useLC_COLLATE=en_US.utf8
. If you want a case sensitive sort, useLC_COLLATE=C
.Also
man bash
: