按文件名的长度对文件名进行排序 [英] Sorting file names by length of the file name
本文介绍了按文件名的长度对文件名进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ls显示目录中可用的文件.我希望根据文件名的长度显示文件名.
ls displays the files available in a directory. I want the file names to be displayed based on the length of the file name.
任何帮助将不胜感激. 在此先感谢
Any help will be highly appreciated. Thanks in Advance
推荐答案
您可以这样做
for i in `ls`; do LEN=`expr length $i`; echo $LEN $i; done | sort -n
这篇关于按文件名的长度对文件名进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文