我有一个awk命令的以下输出..我想美化输出如下..是否有一个sed命令将给我预期的输出?
CURRENT OUTPUT:-
https://code-comp.com/308271
(there is white space line here)
https://code-comp.com/308270
466197
https://code-comp.com/308263
470188
https://code-comp.com/308262
https://code-comp.com/308261
以下是预期的输出
EXPECTED OUTPUT:-
https://code-comp.com/308271
https://code-comp.com/308270 466197
https://code-comp.com/308263 470188
https://code-comp.com/308262
https://code-comp.com/308261
答案 0 :(得分:1)
这可能适合你(GNU sed):
sed -r ':a;$!N;/\nhttps:/!{s/\n/ /;ta};s/\s*(\n|$)/\1/;P;D' file
答案 1 :(得分:0)
sed 'N; /\n[0-9]/s/\n/ /; s/\n$//' foo.txt