0

I have a lot of txt files like this:

Title 1
Text 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?

1

1 Answer 1

1

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.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.