5

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
  • 2
    Does this post contain personal information? – Kusalananda Oct 9 at 7:34
  • 1
    @Kusalananda nope its just a mock data – taufan maulana Oct 9 at 9:41
  • You may find useful csvkit for handling this kind of data. It contains utilities design to work with CSV(-like) data and they can often provide way simpler and more robust solution (think escaping/quoting) than trying to put together sorting/grepping/cutting "by hand". – Bakuriu Oct 9 at 20:00
11
sort -t '|' -k5,5 

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.