목록을 정렬하는 데 문제가 있습니다. 나는 그것들을 함께 묶는 방법이라고 생각한다. 하지만 자세한 내용을 볼 수 있습니다 :bash에서 목록 정렬
큰 (창) - txt 파일이 있습니다. 핫픽스에 대한 Readmes입니다. 나는 다음과 같이이 릴리스에서 해결 된 문제와 핫픽스-번호를 추출 할 :
1378 Issue: Here is the issue that is fixed
1390 Issue: Another issue is fixed
1402 Issue: Yet another fixed issue
나는 다른 후 하나 개의 파일을 계산하는 루프를 가지고있다. 이 루프에서 일부 추출 작업 후 HotFix-Number에 대한 문자열 변수 1 개와 HotFix-Number에 속하는 텍스트 tmp4.txt가 있습니다. 루프의 끝에서
$NR=1378
cat tmp4.txt - Output: Issue: Here is the issue that is fixed
내가 함께이 2 개 개의 구성 요소를 넣어 :
array[IDX]=$(echo $NR $(cat tmp4.txt));
루프가 끝난 후
, 나는 각 인덱스의 내용을 확인. 내가 단일 항목을 에코, 내가 올바른 양식을 얻을 :echo ${array[0]} #output: 1390 Issue: Another issue is fixed
echo ${array[1]} #output: 1378 Issue: Here is the issue that is fixed
echo ${array[2]} #output: 1402 Issue: Yet another fixed issue
...
을하지만
for j in ${array[@]}; do echo "$j"; done | sort -n >> result.txt;
으로 목록을 정렬 할 때 모든 하나의 단어가 알파벳 순으로 정렬되어있는 파일을 얻을. 그러나 나는 단지 HotFix-Number를 참조하기를 원한다.
# Sampleoutput from result.txt for these 3 examples
Another
another
fixed
fixed
fixed
Here
...
Yet
1378
1390
1402
질문을 업데이트하십시오. 이해가되지 않습니다. 특히 마지막 문장! –
[여러 항목으로 목록 정렬] 가능한 중복 (http://stackoverflow.com/questions/16812914/sorting-a-list-with-multi-part-items) –