1

I'm trying to add bullet points to the start of sub-bullet points.

For example, converting this text file:

*foo
  abc
  def
  ghi
*bar
  jkl mno
*hello world
  pqr stu
  vwxyz

Into this text file:

foo, abc
foo, def
foo, ghi
bar, jkl mno
hello world, pqr stu
hello world, vwxyz

This seems easy, and while I have had some ideas, I haven't been able to figure it out.

1

With awk script:

awk '/^\*/{ pfx=substr($0, 2); next }{ print pfx","$0 }' file

The output:

foo,  abc
foo,  def
foo,  ghi
bar,  jkl mno
hello world,  pqr stu
hello world,  vwxyz

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.