Como posso mesclar várias linhas com espaços (linha em branco) separando-as? [fechadas]

1

Gostaria de mesclar as várias linhas de saída a seguir para que elas formem uma única linha:

linha 1:

,,,1,,,,,,,,18,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,42,1,121,1,17,10,21,1,,IU,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**S,,,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,,Usage,Usage,USG,,N,N,0,,1,,TRNT01I,90,,0GRI3,90,,,,,0,1, 1,1,1,1,34111,437956,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,19,,,,,,,,,,,,,,,H,,1,0,1,0

... linha em branco ...

linha 2:

,,,1,,,,,,,,18,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,42,1,121,1,17,10,21,1,,IU,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,,,,,,,,,,,,17,,,,,,,,,9647703 026865,,,,1,,1,0,,,,,,,,,,,,,,,,,,19,0,.061667,19,0,.061667,,,74,1,,,8820807,13790084046,1,130415002 4556817,,,,33399399,,,,,,,,,,,,74,1,,,,,,0,,0,,,,,,GSMT11B**S,,,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,,Usage,Usage,USG,,N,N,0,,1,,ASIA03I,90,,0GRI3,90,,,,,0,1,1,1,1,1,341 12,437956,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,19,,,,,,,,,,,,,,,H,,1,0,1,0

... linha em branco ...

linha 3:

,,,1,,,,,,,,18,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,42,1,121,1,17,10,21,1,,IU,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**S,,,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,,Usage,Usage,USG,,N,N,0,,1,,TRNT01I,90,,0GRI3,90,,,,,0,1,1,1,1,1 ,34113,437956,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,19,,,,,,,,,,,,,,,H,,1,0,1,0

... linha em branco ...

    
por Nagesh Wali 06.09.2013 / 12:09

2 respostas

2

Se eu entendi sua pergunta corretamente, você tem o seguinte:

$ echo -e "line1\nline2\nline3\n"
line1
line2
line3

$

E você quer isso:

line1line2line3

Portanto, você só precisa remover as linhas em branco. Um comando como este deve fazer isso:

$ echo -e "line1\nline2\nline3\n" | paste -s -d ''
line1line2line3

Não sei ao certo onde sua saída está sendo mantida, mas se estiver em um arquivo, você deve usar o acima para mesclar as linhas:

$ paste -s -d '' somefile.txt 
line1line2line3
    
por 06.09.2013 / 13:48
1

Outra abordagem seria simplesmente remover as novas linhas do seu arquivo:

echo $(tr -d '\n' < file) > newfile

Estou usando o echo para inserir uma nova linha final, se você nem quer que seja executado

tr -d '\n' < file > newfile
    
por 06.09.2013 / 19:06