Join을 사용하여 두 파일을 결합하는 스크립트에 몇 가지 문제가 있습니다. 샘플 입력 파일에는 다음과 같은 줄이 포함되어 있습니다.
다음은 Join 명령의 입력 파일 및 출력입니다.
D:\work\BuildScripts\3C>cat D:\temp\aaa.txt
hzapplications\adn\adn4\adn4density\adn4_idd_module.cpp,83
hzapplications\adn\adn4\adn4density\adn4dencalmodule.cpp,73
hzapplications\adn\adn4\adn4density\adn4denimagemodulerm.cpp,111
hzapplications\adn\adn4\adn4density\adn4denimagemodulert.cpp,202
hzapplications\adn\adn4\adn4density\adn4densityanqmodules.cpp,445
hzapplications\adn\adn4\adn4density\adn4densityappl.cpp,378
hzapplications\adn\adn4\adn4density\adn4densityappl.h,50
hzapplications\adn\adn4\adn4density\adn4densityevrmodules.cpp,272
hzapplications\adn\adn4\adn4density\adn4densitykernel.cpp,490
hzapplications\adn\adn4\adn4density\adn4densitykernel.h,65
hzapplications\adn\adn4\adn4density\adn4densitysecimgmodule.cpp,209
hzapplications\adn\adn4\adn4density\adn4densitysecimgmodule.h,70
hzapplications\adn\adn4\adn4density\adn4densitysecmodule.cpp,218
hzapplications\adn\adn4\adn4density\adn4densitysecmodule.h,70
hzapplications\adn\adn4\adn4density\adn4dphimodules.cpp,610
hzapplications\adn\adn4\adn4density\adn4dphimodulesrt.cpp,115
hzapplications\adn\adn4\adn4density\adn4rhomodulesrt.cpp,102
D:\work\BuildScripts\3C>cat D:\temp\bbb.txt
hzapplications\activect\ptc\ictsx01\ictsx01_bootuptask.cpp,1
hzapplications\activeps\iola\acquisition\iola_acqmodule.cpp,4
hzapplications\activeps\iola\simulation\iola_simmodule.cpp,3
hzapplications\activeps\iolr\simulation\iolr_simmodule.cpp,1
hzapplications\activeps\iolr\task\iolr_poweron200vhitask.cpp,1
hzapplications\activeps\iolr\task\iolr_poweron200vlowtask.cpp,1
hzapplications\activeps\iolr\task\iolr_poweronnrlvtask.cpp,1
hzapplications\activeps\iolr\task\iolrtaskcommon.cpp,2
hzapplications\adn\adn4\adn4density\adn4densitykernel.cpp,1
hzapplications\adn\adn4\adn4equipment\adn4adseelem.cpp,1
hzapplications\adn\adn4\adn4equipment\adn4collar.cpp,1
hzapplications\adn\adn4\adn4equipment\adn4tool.cpp,2
hzapplications\adn\adn6c\adn6cequipment\adn6ccollar.cpp,1
hzapplications\adn\adn8\adn8equipment\adn8tool.cpp,1
hzapplications\adn\adn8\adn8neutron\adn8neutronkernel.cpp,1
hzapplications\adn\adn8d\adn8ddensity\adn8ddensitykernel.cpp,1
hzapplications\adn\adn8d\adn8dequipment\adn8dtool.cpp,1
D:\work\BuildScripts\3C>join --ignore-case -1 1 -2 1 -t"," -o "1.1,1.2,2.2" -e "0" -a 1 D:\temp\aaa.txt D:\temp\bbb.txt
hzapplications\adn\adn4\adn4density\adn4_idd_module.cpp,83,0
hzapplications\adn\adn4\adn4density\adn4dencalmodule.cpp,73,0
hzapplications\adn\adn4\adn4density\adn4denimagemodulerm.cpp,111,0
hzapplications\adn\adn4\adn4density\adn4denimagemodulert.cpp,202,0
hzapplications\adn\adn4\adn4density\adn4densityanqmodules.cpp,445,0
hzapplications\adn\adn4\adn4density\adn4densityappl.cpp,378,0
hzapplications\adn\adn4\adn4density\adn4densityappl.h,50,0
hzapplications\adn\adn4\adn4density\adn4densityevrmodules.cpp,272,0
hzapplications\adn\adn4\adn4density\adn4densitykernel.cpp,490,0
hzapplications\adn\adn4\adn4density\adn4densitykernel.h,65,0
hzapplications\adn\adn4\adn4density\adn4densitysecimgmodule.cpp,209,0
hzapplications\adn\adn4\adn4density\adn4densitysecimgmodule.h,70,0
hzapplications\adn\adn4\adn4density\adn4densitysecmodule.cpp,218,0
hzapplications\adn\adn4\adn4density\adn4densitysecmodule.h,70,0
hzapplications\adn\adn4\adn4density\adn4dphimodules.cpp,610,0
hzapplications\adn\adn4\adn4density\adn4dphimodulesrt.cpp,115,0
hzapplications\adn\adn4\adn4density\adn4rhomodulesrt.cpp,102,0
D:\work\BuildScripts\3C>
예상되는 출력은 이 특정 줄이 다음과 같이 연결된다는 것입니다: hzapplications\adn\adn4\adn4densis\adn4densiskernel.cpp,490,1
어떤 제안이라도 매우 환영합니다. Windows에서 unxutils 패키지를 사용하고 있으며 이것이 정확한 버전입니다.
D:\work\BuildScripts\3C>join --version
join (GNU textutils) 2.0
Written by Mike Haertel.
Copyright (C) 1999 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
답변1
--ignore-case
그게 문제인 것으로 밝혀졌습니다 . 모든 소문자를 대문자로 처리하여 ASCII 순서에 따라 대문자와 소문자 사이의 문자 반대쪽으로 점프하기 때문에 대문자 없이도 효과가 있습니다.[\]^_
일반적인 정렬 순서에서는 iolrt
마지막 에 오지만 역순 iolr_
입니다 .--ignore-case
이 sort
명령에는 -f
올바른 시퀀스를 생성하는 옵션이 필요합니다. ( -t,
및 제외 -k1,1
)