查找Linux中最小文件的名称? [英] Find name of smallest file in Linux?

查看:164
本文介绍了查找Linux中最小文件的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您必须在目录中找到第4个最小(非隐藏)文件的名称

Suppose that you have to find the name of the 4th smallest (non-hidden) file in the directory

执行此操作的正确命令是什么?假设我是一个只知道ls -lheadtaillineawk '{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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆