![如何在bash上使用分隔符根据列上的数字进行排序](https://linux22.com/image/161926/%E5%A6%82%E4%BD%95%E5%9C%A8bash%E4%B8%8A%E4%BD%BF%E7%94%A8%E5%88%86%E9%9A%94%E7%AC%A6%E6%A0%B9%E6%8D%AE%E5%88%97%E4%B8%8A%E7%9A%84%E6%95%B0%E5%AD%97%E8%BF%9B%E8%A1%8C%E6%8E%92%E5%BA%8F.png)
如何按第五列对这些数据进行排序
PREPAID|085319338982|Replacement Card|2016-05-31 15:15:29|218BKSAT||14121837 | 0
PREPAID|08128352315|Replacement Card|2016-05-31 15:15:33|218KKSAT||14121842 | 0
POSTPAID|085283124329|Replacement Card|2016-05-31 15:15:47|128PDGAT||14121855 | 0
PREPAID|081220000852|Replacement Card|2016-05-31 15:16:06|118GMPAT||14121863 | 0
PREPAID|082210381832|Replacement Card|2016-05-31 15:17:16|218PIMAT||14121912 | 0
POSTPAID|085348838969|Replacement Card|2016-05-31 15:17:22|418BPPAT||14121917 | 0
PREPAID|082132221987|Replacement Card|2016-05-31 18:21:10|328PMRAT||14126628 | 0
PREPAID|08128223567|Replacement Card|2016-05-31 18:22:02|218JBKAT||14126637 | 0
PREPAID|081319486899|Replacement Card|2016-05-31 18:22:52|218BKSAT||14126645 | 0
PREPAID|085207770888|Replacement Card|2016-05-31 18:23:39|118GMPAT||14126649 | 0
PREPAID|081288282777|Replacement Card|2016-05-31 18:24:13|218PIMAT||14126657 | 0
POSTPAID|081324559128|Replacement Card|2016-05-31 18:24:29|228BC2AT||14126660 | 0
PREPAID|08123968211|Replacement Card|2016-05-31 18:25:38|338KUTAT||14126675 | 0
PREPAID|081281623923|Replacement Card|2016-05-31 18:25:45|218JKBAT||14126676 | 0
PREPAID|081333293977|Replacement Card|2016-05-31 18:25:53|328MLGAT||14126679 | 0
POSTPAID|081312544456|Replacement Card|2016-05-31 18:25:56|228BC2AT||14126680 | 0
答案1
sort -t '|' -k5,5
用作|
字段分隔符,仅按第五列排序。