查找Linux中最小文件的名称? [英] Find name of smallest file in Linux?
本文介绍了查找Linux中最小文件的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设您必须在目录中找到第4个最小(非隐藏)文件的名称
Suppose that you have to find the name of the 4th smallest (non-hidden) file in the directory
执行此操作的正确命令是什么?假设我是一个只知道ls -l
,head
,tail
,line
和awk '{print}'
语句的人.
What is the right command to do this? Suppose I'm a guy who only knows ls -l
, head
, tail
, line
, and awk '{print}'
statement.
推荐答案
来自man ls
:-S
按大小降序对输出进行排序,-r
反转输出的顺序
From man ls
: -S
sorts the output by size descending, -r
reverses the order of the output
所以我的解决方案看起来像
So my solution would look like
ls -rS | sed -n '4p'
或者,或者
ls -rS | awk 'NR==4'
这篇关于查找Linux中最小文件的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文