简体   繁体   中英

How to sort files in a folder in Mac using Terminal?

If I have 3 files in a folder.The names of files are:

0A1c.png 
0A93.png
00A4.png

MacOS sort performs numerical sort in finder and after sorting the order of files is:

0A1c.png
00A4.png
0A93.png

Numerically, 0 and 00 are equal, there 00A4 comes before 0A93 in numerical sorting.

I need to perform character sorting based up ASCII value of each character such that the resulting order of files after sorting is:

00A4.png
0A1c.png
0A93.png

Typing the ls command in command prompt list all files sorted based upon character value which is the order I need in finder. What command can I use in terminal to perform character sorting of files in a folder?

只需使用默认情况下按字母顺序sort

ls | sort

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM