다음 여러 줄의 출력을 병합하여 단일 줄을 형성하고 싶습니다.
라인 1:
,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,42,1,121,1,17,10,21,1,,아이유,8,0,,0,,0,0,0,,, ,,,,,,,,,,,,,,,,,,,,,1227,,,11,,0,,,,1,01,,,1,12769,,7707,0,, ,, 12769,,,12769,6,0,,,,10,,,1, 901,10800,14/04/13,,,4,,,,2,,,,,,,,,, ,, ,,,,,,,,,,,,,,,,A,,,,1001,,,,,,,,,,,01,,12769,0,,,,,,,,, ,, ,,,,,,,,,,,,,,,,,,14/04/13,10800,,,,,,,,,,,,,,,,,,,,, 1,, ,,,,,,,,964750001210,,1001,,1,,0,,,,,,,,,,,17,,,,,,,,,,31685125704,,,,1 ,,1,0 ,,,,,,,,,,,,,,,,,,19,0,.901,19,0,.901,,,901,1,,,8767318,13790084045, 1, 1304150024556817,,, ,33399399,,,,,,,,,,,,901,1,,,,,,0,,0,,,,,GSMT11B**에스,,,4,,,,,10800,14/04/1 3,10800,14/04/13,443867992,,,,,,,,1,0,,0,,,,,,,61409 ,51,,9647507763683,,1001,1,0,,60,0,5,,N,,0,1,I, 1,,,,,,47,,,,,,54,1,4 , 19,,29,1,1,1,3,1112,2,,사용법,사용법,USG,,N,N,0,,1,,TRNT01I,90,,0GRI3,90,,,,,0 , 1, 1,1,1,1,34111,437956,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,, ,,,,,19,,,,,,,,,,,,,,,H,,1,0,1,0
...빈 줄...
2호선:
,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,42,1,121,1,17,10,21,1,,아이유,8,0,,0,,0,0,0,,, ,,,,,,,,,,,,,,,,,,,,,399,,,11,,0,,,,1,01,,,1,61,,67,0,, ,, 61,,,61,6,0,,,,10,,1,74,10800,14/ 04/13,,,4,,,,2,,,,,,,,,,, ,, , ,,,,,,,,,,,,,,,,A,,,,1001,,,,,,,,,,,01,,61,0,,,,,,, ,,, ,, ,,,,,,,,,,,,,,,,,,,,14/04/13,10800,,,,,,,,,,,,,,,,,, ,,,, 1,,,,,,,,,,964750001210,,1001,,1,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9647703 026865, ,,,1, ,1, 0,,,,,,,,,,,,,,,,,19,0,.061667,19,0,.061667,,,74,1,,,8820807 ,13790084046,1, 130415002 4556817,,,,33399399,,,,,,,,,,,,,74,1,,,,,,0,,0,,,,,,GSMT11B**에스,,,4,,,,,10800,14/04/13,10800,14/04/13,443867993,,,,,,,,1,0,,0,,,,,61409,51 ,,,9647503228592,,1001,1,0,,60,0,5,,N,,0,1,I,1,,,,,,20, ,,,,25,1,4,19, ,19,1,1,1,3,980,2,,용도,용도,USG,,N,N,0,,1,,ASIA03I,90,,0GRI3,90,,,,,0,1, 1, 1,1,1,341 12,437956,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,19,,,,,,,,,,,,,,,,,H,,1,0,1,0
...빈 줄...
3행:
,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,42,1,121,1,17,10,21,1,,아이유,8,0,,0,,0,0,0,,, ,,,,,,,,,,,,,,,,,,,,,327,,,11,,0,,,,1,01,,,1,12769,,7707,0,, ,, 12769,,,12769,6,0,,,,10,,,1,2 ,10800,14/04/13,,,4,,,,2,,,,,,,,,, ,, ,,,,,,,,,,,,,,,,A,,,,1001,,,,,,,,,,,01,,12769,0,,,,,,,,, ,, ,,,,,,,,,,,,,,,,,,14/04/13,10800,,,,,,,,,,,,,,,,,,,,, 1,, ,,,,,,,,964750001210,,1001,,1,,0,,,,,,,,,,,17,,,,,,,,96171254836,,,,1, ,1,0 ,,,,,,,,,,,,,,,,,,19,0,.002,19,0,.002,,,2,1,,,8825322,13790084047,1 ,13041 50024556817,, ,,33399399,,,,,,,,,,,,2,1,,,,,,0,,0,,,,,GSMT11B**에스,,,4,,,,,10800,14/04/13,10800 ,14/04/13,443867994,,,,,,,,1,0,,0,,,,,,,61409, 51,,,9647501378572,,1001,1,0,,60,0,5,,N,,0,1,I,1,,,,,,47,,,,,54,1,4,19 ,,29,1,1,1,3,1112,2,,사용법,사용법,USG,,N,N,0,,1,,TRNT01I,90,,0GRI3,90,,,,,0,1 ,1,1,1,1 ,34113,437956,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, , ,,,,19,,,,,,,,,,,,,,,H,,1,0,1,0
...빈 줄...
답변1
귀하의 질문을 올바르게 이해했다면 다음과 같은 내용이 있습니다.
$ echo -e "line1\nline2\nline3\n"
line1
line2
line3
$
당신은 이것을 원합니다 :
line1line2line3
따라서 빈 줄만 제거하면 됩니다. 다음과 같은 명령이 트릭을 수행해야 합니다.
$ echo -e "line1\nline2\nline3\n" | paste -s -d ''
line1line2line3
출력이 어디에 저장되어 있는지 잘 모르겠지만 파일에 있는 경우 위의 내용을 사용하여 줄을 병합해야 합니다.
$ paste -s -d '' somefile.txt
line1line2line3
답변2
또 다른 방법은 파일에서 새 줄을 제거하는 것입니다.
echo $(tr -d '\n' < file) > newfile
echo
실행하고 싶지 않은 경우 마지막 새 행을 삽입하고 있습니다 .
tr -d '\n' < file > newfile