Is it attainable in MacOS Terminal to have the kind order numerically and case-insensitively, virtually like in Finder?
I am on MacOS 14 Sonoma, utilizing Terminal app with zsh 5.9 and oh-my-zsh.
I am making an attempt to execute some command line for all information in a particular folder.
Please evaluate:
My desired type order | MacOS Finder type by identify order |
---|---|
bar.jpg bar-2.jpg bar-10.jpg foo.jpg foo-1.jpg foo-2.jpg foo-10.jpg STA.jpg STA-3.jpg STA-20.jpg |
bar-2.jpg bar-10.jpg bar.jpg foo-1.jpg foo-2.jpg foo-10.jpg foo.jpg STA-3.jpg STA-20.jpg STA.jpg |
The Finder means could be superb, however not best, because it leaves foo.jpg beneath foo-1.jpg
Listed below are instructions I attempted:
for file in *; do echo $file; accomplished | for file in *(n); do echo $file; accomplished |
---|---|
STA-20.jpg STA-3.jpg STA.jpg bar-10.jpg bar-2.jpg bar.jpg foo-1.jpg foo-10.jpg foo-2.jpg foo.jpg |
STA-3.jpg STA-20.jpg STA.jpg bar-2.jpg bar-10.jpg bar.jpg foo-1.jpg foo-2.jpg foo-10.jpg foo.jpg |
The latter brings in numerical type order and is the closest I may get to Finder, however leaves uppercase STA* information above lowercase bar* ones.
I attempted to make use of glob qualifier trigger it appeared like the only syntax, but when it isn’t achievable – please recommend different methods to execute instructions on a number of information after sorting them the way in which I would like.