bash - 排序数据卷号
问题描述
您能否让我知道是否有一种方法可以对数据卷号进行排序,如下所示:
想要根据第一列对以下行进行排序
7.9G User1 2020-05-07
529M User2 2020-04-24
49M User3 2020-04-29
43M User4 2020-04-23
谢谢
解决方案
使用 GNU 排序,使用以下-h
选项:
sort -k1,1h file
来自man sort
:
-h, --human-numeric-sort
compare human readable numbers (e.g., 2K 1G)
-k, --key=KEYDEF
sort via a key; KEYDEF gives location and type
KEYDEF is F[.C][OPTS][,F[.C][OPTS]] for start and stop position,
where F is a field number and C a character position in the field;
both are origin 1, and the stop position defaults to the line's end.
推荐阅读
- android - Firestore 安全规则 request.query.orderBy 不起作用
- java - 播放框架依赖注入不起作用
- angular - angular-devkit/build-angular 版本 0.13.4 - configuration.output 具有未知属性“futureEmitAssets”
- java - 如何在偶数索引上创建具有反转元素并在奇数索引上求和数字的新数组
- python - 如何从 Jupyter Notebook 中的 PySpark 远程连接到 Greenplum 数据库?
- ios - didReceiveRemoteNotification 函数调用了两次
- php - 如何使用证书发送 SOAP 数字签名消息
- qt - Qt BLE QLowEnergyDescriptor characteristicChanged(桌面操作系统)
- sql - 如何使用 ROLLUP 将总计移动到结果集的底部?
- python-3.x - 无法弄清楚Chatterbot的这个问题