我想合并以下多行输出,使它们形成一行:
第 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,,用法,用法,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,,,,,,,,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,,使用情况,使用情况,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,,,,,,,,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,,用法,用法,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