Artificial intelligent assistant

Extract text between two characters (multiline input) If I have the text: aaaaaaaaa #some info other rows end row# another info How could I extract only the text between the characters `#` obtaining only: some info other rows end row I was trying with `sed` in this way: echo -e "aaaaaaaaa\n#some info\nother rows\nend row#\nanother info" | sed -n -e '/\#/,/\#/p' but it gives me also the character `#`. Is there a way to remove `#` using `sed`?

You can use `perl`:


echo -e "aaaaaaaaa\
#some info\
other rows\
end row#\
another info" |\
perl -0777 -ne '/#([^#]*)#/ && print $1,"\
"; '


Explanation:

* `-0777` slurp the whole file as one line (enables multiline matching)
* `/#([^#]*)#/` match non-# characters `[^#]` between too `#` and with the brackets add it as first matching group.
* `&& print $1,"\
"` if found, print first matching group and a final newline.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy ddadd5228a915153303929f30fde0aef