shell - Joining truncated lines in a file -


i have file broken lines follows,

c12321 net12415431 net41432143 +  1.079879e-17 c12322 net2135 net648641 +  3.4659e-17 

i want create file file has lines follows

c12321 net12415431 net41432143 1.079879e-17 c12322 net2135 net648641 3.4659e-17 

i need using sed or awk in couple of lines.

regards, asif

sed excellent tool simple substitutions on single line other text manipulation use awk - solution clearer, more extensible, more robust, more portable, , in many cases briefer (not that matters much).

read file , remove occurrences of " +\n" (space-plus-newline):

$ cat file c12321 net12415431 net41432143 +  1.079879e-17 c12322 net2135 net648641 +  3.4659e-17  $ awk -v rs= '{gsub(/ \+\n/,""); print}' file c12321 net12415431 net41432143 1.079879e-17 c12322 net2135 net648641 3.4659e-17 

there many alternatives, briefer, using less memory, etc. clearest imho.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -