linux - 将具有最小大小的子文件夹的路径存储到变量中
问题描述
我为 bash 编写了一些代码,我需要将一组文件夹的最小大小存储在一个目录中,数据集将来自类似du
.
例如
du -hd1 /path/to/dir/
5GB /path/to/dir/1
1GB /path/to/dir/2
2GB /path/to/dir/3
3GB /path/to/dir/4
4GB /path/to/dir/5
在这种情况下,如何将 的值存储/path/to/dir/2
到变量中$smallest
?
解决方案
不需要awk
_
du -d1 /path/to/dir | sort -n | head -1 | cut -f 2
推荐阅读
- android - 是否可以在不在 Firestore 中添加文档的情况下将子集合添加到集合中?
- excel - 如何将工作簿表添加到另一个工作簿中
- amazon-web-services - AWS Lambda 函数在调用 aws 服务时超时
- sqlite - @capacitor-community/sqlite 中的“加密”、“秘密”和“新秘密”三种模式有什么区别?
- javascript - 初始化 RTCPeerConnection 时如何禁用 Chromium 入站权限请求
- java - lwjgl 中的缓冲实用程序导致内存泄漏
- r - 在R中使用map()函数循环时如何获取变量的名称而不是x?
- c# - 如何将 gsm 调制解调器自动连接到可用的 COM 端口(没有组合框)
- matlab - 在 Matlab 中应用拉普拉斯滤波器
- javascript - 新年计时器无法设置属性