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 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .