开发者

Making csv from text using awk

I have a lot of txt files like this:

Title 1
Text 开发者_JS百科1

And I would like to make one csv file from all of them that it will look like this:

Title 1,Text 1
Title 2,Text 2
Title 3,Text 3
etc

How could I do it using awk?


Without knowing any more detail, the following answers look like good options:

awk '{printf "%s,", $0; getline; print}'
# every second line gets merged with the previous line

or

awk \
'
  $0 ~ /^Title/ {printf "\n"}
  {printf "%s,", $0}
'
# every line that starts with Title starts
# a newline and the rest is merged into one
# long line separated by commas.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜