如何获取find命令以文件名打印文件大小?(How do I get the find command to print out the file size with the file name?)

编程入门 行业动态 更新时间:2024-10-24 17:28:38
如何获取find命令以文件名打印文件大小?(How do I get the find command to print out the file size with the file name?)

如果我发出find命令如下:

$ find . -name *.ear

它打印出来:

./dir1/dir2/earFile1.ear ./dir1/dir2/earFile2.ear ./dir1/dir3/earFile1.ear

我想要打印到命令行是名称和大小:

./dir1/dir2/earFile1.ear 5000 KB ./dir1/dir2/earFile2.ear 5400 KB ./dir1/dir3/earFile1.ear 5400 KB

If I issue the find command as follows:

$ find . -name *.ear

It prints out:

./dir1/dir2/earFile1.ear ./dir1/dir2/earFile2.ear ./dir1/dir3/earFile1.ear

What I want to 'print' to the command line is the name and the size:

./dir1/dir2/earFile1.ear 5000 KB ./dir1/dir2/earFile2.ear 5400 KB ./dir1/dir3/earFile1.ear 5400 KB

最满意答案

find . -name '*.ear' -exec ls -lh {} \;

只是从jer.drab.org的回复的h额外。 节省时间转换成MB精神;)

find . -name '*.ear' -exec ls -lh {} \;

just the h extra from jer.drab.org's reply. saves time converting to MB mentally ;)

更多推荐

本文发布于:2023-07-26 19:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1279919.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件大小   文件名   命令   find   size

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!