您好我需要根据列字段值对bcp文件进行排序。其中字段分隔符用作\ x01和行separa tor用作\ x02。所有信息都存储在bcp文件的单行中。 我尝试过以下查询
sort -t \ x01 -z \ x02 -k2n,2n -o sorted_data _ date "+%m%d%y%H%M%S"
。bcp /BNYM/act_agent_events_AgDrCUa5Uiw7kHq5NgGoIBWs_133456.bcp
但它没有根据第二列排序 米 附加bcp文件。 请帮助我如何根据第二列(在日期值之后)对文件进行排序
2012-04-16 10:35:16.117BAAAAC0000-6TgTbL12lFR9uTYB-8A0251CAAABY25JFX6XZfri6NgGoIBWs30004373120010840 / LogisticsMgr / DeliveryLogisticsMgrDeliveryCheckStatusLogisticsMgrqwQzeSlY7aWIcu6jFxHS / Q == wBkxsG + SGmPkV8Cz7LoMvw == logistics652841288162400nbhydsoletixp9.00002012-04-16 10:35:16.120BAAAAB0000-6TgTbL12lFR9uTYB-8A0251CAAADUsVwslC8nf7i6NgGoIBWs30003762320010090 / AccountMgmt /BillingAccountMgmtBillingChargeAccountAccountMgmtdNCvO/2f5LX3BjewCbfCaA==zhdycSzBtfdvoeEC8hPLfA==finance652845508162400nbhydsoletixp9.00002012-04-16 10:35:16.137AQBRv3dT4YnZfri6NgGoIBWs0000-6TgTbL12lFR9uTYB-8A0251CAAABRv3dT4YnZfri6NgGoIBWs30003044870011040 / OrderManagement / OrderingOrderManagementOrderingCheckStatusOrderManagementPTWWE0wTSwsQZMYEQ4g6RQ == 0KtezUvQkOOkSrTAhl455w == ordermgmt652841378162400ordermgmt1.writenow.com9.00002012-04-16 10:35: 16.109AAAoQXS2OW7Zfri6NgGoIBWs0000-6TgTbL12lFR9uTYB-8A0251CAAAAoQXS2OW7Zfri6NgGoIBWs30003913990010760 / StockApp / StockServiceStockAppStockServiceStockCheckStockAppV3UuJQeiUa4b + DydaHy 3FQ == mnn8 + QVDZ + Clj8Fyz7ddsA == warehouseamericas652841368162400nbhydsoletixp9.00002012-04-16 10:35:16.102AcD0000-6TgTbL12lFR9uTYB-8A0251CAAACs2k00egPZfri6NgGoIBWs30003443250010840 / LogisticsMgr / DeliveryLogisticsMgrDeliveryCheckStatusLogisticsMgrqwQzeSlY7aWIcu6jFxHS / Q == wBkxsG + SGmPkV8Cz7LoMvw == logistics652841288162400nbhydsoletixp9.00002012-04-16 10:35 :16.141QAqSPLPSqLZfri6NgGoIBWs0000-6TgTbL12lFR9uTYB-8A0251CAAAAqSPLPSqLZfri6NgGoIBWs30003973920011080 / OrderingServices / OrderingOrderingServicesOrderingCheckStatusOrderingServicesCVim6lKsl / QGDrErqenNdg == 13RQpOOyOFvxX7p5dAzVdQ == customergw652841248172400custgw1.writenow.com9.00002012-04-16 10:35:16.125AQDO.WX2ikQnf7i6NgGoIBWs0000-6TgTbL12lFR9uTYB-8A0251CAAADO.WX2ikQnf7i6NgGoIBWs30003943690010140 / AccountMgmt / BillingAccountMgmtBillingChargeAccountAccountMgmtdNCvO / 2f5LX3BjewCbfCaA = = zhdycSzBtfdvoeEC8hPLfA == finance652845508162400nbhydsoletixp9.0000
答案 0 :(得分:0)
我没有你的原始文件,但我认为这可能有效。
sort -t \ x01 -z \ x02 -k 2n
面对这个问题,我会用sed按摩然后把它管道排序。
此外,如果您可以控制bcp命令的运行方式,可以添加-c选项为其提供换行符,这样可以简化操作。