Print all lines that start with * foo
to any next line that starts with *
I thought that this would work, but it only prints the first lines:
awk '/^\* foo/,/^\* /' file.org
results in:
* foo
example file (org-mode):
* foo
** subheading
- item 1
- item2
comments
* bar
** subheading
more text
Given your response to the other answer it appears you want output for your sample to be:
* foo
** subheading
- item 1
- item2
comments
* bar
For this, you might be able to use sed
which unlike awk
does not check both start and end condition on the same iteration:
sed -n '/^\* foo/,/^\* /p' file.org
Note that more complicated input may not produce the output you want. For example, this input:
* foo
** subheading
- item 1
- item2
comments
* foo too
** should this print?
- or this?
* bar
** subheading
more text