我正在尝试使用以下命令基于字段位置对文件进行排序:
sort -d -k 2.42,44 -k 4.65,74
但是当我检查输出文件是否已经排序(sort -c)时,其中一行总是乱序。要排序的文件如下:
000835NMSEFT 20140626095038403536
010835 577300053D0000000031860CZZBCCP01122000496 DA 2270000323 133052649999999999901121000358 DA 1235565067 201406301EG11388791 1953760980999999999 TN HCCLAIMPMT 40520140625PRREEP 21555 OXNARD STREET WOODLAND HILLS CA91367 BLEDI SOLUTIONS TE8002273983 IC URwww.anthem.com/provider/router PETWIN CITIES COMMUNITY HOS XX1396778197 FILE 57446 LOS ANGELES CA90074 TJ 752918765-0506330000-000 PN 050633-003 EY DCCP13305264991953760980 050633-003NMSINS 201406255004000270000323 0003230001 2014I 050633-003 00004 01505000323050633-003 00004
000835NMSEFT 20140626095038403536
010835 577300054D0000000002162CZZHCCP01122000496 DA 2270000323 133052649999999999901122000030 DA 1452500273 201406301EG11388792 1953760980999999999 TN HCCLAIMPMT 40520140625PRREEP 21555 OXNARD STREET WOODLAND HILLS CA91367 BLEDI SOLUTIONS TE8002273983 IC URwww.anthem.com/provider/router PESCRIPPS CLINIC XX1538297726 10666 N TORREY PINES RD S LA JOLLA CA92037 TJ 870737749-0000000000-000 BY DCCP13305264991953760980 870737749 NMSPRF 201406254004000270000323 0003230001 2014P 870737749-00300010 01405000323870737749-00300010
000835NMSEFT 20140626095038403536
010835 577300074D0000000002000CACHCCP01191179439 DA 3350209432 191179439099999999901121000358 DA 1459336554 201406301EG11388801 1953760980999999999 TN HCCLAIMPMT 40520140625PRALVORD UNIFIED SCHOOL DISTRICT 21555 OXNARD STREET WOODLAND HILLS CA91367 BLEDI SOLUTIONS TE8002273983 IC URwww.anthem.com/provider/router PEUSC CARE MEDICAL GROUP IN XX1902846306 50938 FILE LOS ANGELES CA90074 TJ 954540991-0000000000-000 EY DCCP19117943901953760980 954540991 NMSPRF 201406254022603350209432 2094320001 2014P 954540991 00045 01403209432954540991 00045
000835NMSEFT 20140626095038403536
010835 577300075D0000000021553CABHCCP01122000496 DA 2640001855 194147704099999999901121141819 DA 0009605886 201406301EG11388802 1953760980999999999 TN HCCLAIMPMT 40520140625PRHOOPA VALLEY TRIBAL COUNCIL 21555 OXNARD STREET WOODLAND HILLS CA91367 BLEDI SOLUTIONS TE8002273983 IC URwww.anthem.com/provider/router PEEUREKA FAMILY PRACTICE IN XX1114965761 2675 HARRIS ST EUREKA CA95503 TJ 941724607-0000000000-000 PN 941724 BY DCCP19414770401953760980 941724607 NMSPRF 201406254023202640001855 0018550001 2014P 941724607 00013 01405001855941724607 00013
000835NMSEFT 20140626095038403536
010835 577300076D0000000004819CABBCCP01122000496 DA 2640001855 194147704099999999901121141819 DA 990487159 201406301EG11388803 1953760980999999999 TN HCCLAIMPMT 40520140625PRHOOPA VALLEY TRIBAL COUNCIL 21555 OXNARD STREET WOODLAND HILLS CA91367 BLEDI SOLUTIONS TE8002273983 IC URwww.anthem.com/provider/router PEHUMBOLDT RADIOLOGY MED GR XX1326154196 PO BOX 6428 EUREKA CA95502 TJ 942188987-0000000000-000 EY DCCP19414770401953760980 942188987 NMSPRF 201406254023202640001855 0018550001 2014P 942188987 00004 01405001855942188987 00004
000835NMSEFT 20140626095038403536
010835 577300079D0000000010320CDAHCCP01122000496 DA 4000155328 133017499699999999901323070380 DA 485008267910 201406301EG11388804 1953760980999999999 TN HCCLAIMPMT 40520140625PRVIASAT, INC 21555 OXNARD STREET WOODLAND HILLS CA91367 BLEDI SOLUTIONS TE8002273983 IC URwww.anthem.com/provider/router PEWEST PACIFIC MEDICAL LABO XX1124050380 PO BOX 2339 SANTA FE SPGS CA90670 TJ 954391299-0000000000-000 BY DCCP13301749961953760980 954391299 NMSPRF 201406254025104000155328 1553280001 2014P 954391299 00025 01405155328954391299 00025
答案 0 :(得分:0)
两个问题。小数点后面的数字是字段中的字符位置(不是从行的开头)。你需要在逗号后重复字段编号。所以:
sort -k 2.25,2.27 -k 4,4