我的文件中有多行,想要合并第一行和第二行,依此类推。将________
视为第二行中的空格。
u_pcrd_logic/CTS_ccl_INV_clk_G1_L17_206
________________________________2.001e+08 2.001e+08 0.0001773 0.001871 2.427e-07 0.002048 0.02934 INV_X6N_A9TL_C16
RC_CG_HIER_INST353/RC_CGIC_INST
______________________________2.001e+08 2.001e+08 0.0004888 0.001523 4.51e-07 0.002012 0.02882 PREICG_X6R_A9TL_C16
预期产出:
u_pcrd_logic/CTS_ccl_INV_clk_G1_L17_206 2.001e+08 2.001e+08 0.0001773 0.001871 2.427e-07 0.002048 0.02934 INV_X6N_A9TL_C16
RC_CG_HIER_INST353/RC_CGIC_INST 2.001e+08 2.001e+08 0.0004888 0.001523 4.51e-07 0.002012 0.02882 PREICG_X6R_A9TL_C16
感谢。
答案 0 :(得分:1)
使用sed:
$ sed '$!N;/ *\n */s// /;P;D' file
u pcrd logic/CTS ccl INV clk G1 L17 206 2.001e+08 2.001e+08 0.0001773 0.001871 2.427e-07 0.002048 0.02934 INV X6N A9TL C16
RC CG HIER INST353/RC CGIC INST 2.001e+08 2.001e+08 0.0004888 0.001523 4.51e-07 0.002012 0.02882 PREICG X6R A9TL C16
答案 1 :(得分:0)
您可以使用以下 spc.awk 脚本:
# spc.awk script
/^ / { #if the line starts with space
lines=lines $0 # add the current line to the former recorded lines
next
}
{ # for every other line ...
print lines # print the recorded lines
lines=$0 # record current line
}
END { print lines } # in the end print the last recorded lines
然后使用命令:
awk -f spc.awk your_input_file
答案 2 :(得分:0)
另一个awk
$ awk -v RS= -v ORS="\n\n" '{$1=$1}1' file
u_pcrd_logic/CTS_ccl_INV_clk_G1_L17_206 2.001e+08 2.001e+08 0.0001773 0.001871 2.427e-07 0.002048 0.02934 INV_X6N_A9TL_C16
RC_CG_HIER_INST353/RC_CGIC_INST 2.001e+08 2.001e+08 0.0004888 0.001523 4.51e-07 0.002012 0.02882 PREICG_X6R_A9TL_C16
连接直到一条空行(记录中断),用额外的空行打印。