Skip to main content

how to sort based on numbers on column with seperator on bash [Resolved]

how to sort these data by fifth column

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

Question Credit: taufan maulana
Question Reference
Asked October 9, 2019
Posted Under: Unix Linux
10 views
1 Answers

sort -t '|' -k5,5 

Using | as the field separator, this sorts by the 5th column only.


credit: cas
Answered October 9, 2019
Your Answer