0

I am having issues trying to parse / grep / pcregrep potentially multiple line environment variable values from the output of the env system command. I am trying to get just the variables that start with a certain prefix that may or not be multiple lines. So far I have been trying variants of this (with a lookahead):

env | pcregrep -M '^PREFIX_\S+\=[\S\s]+(?=^\S+\=.*$)'

But the above returns everything. I think it is because the middle pattern is greedy with newlines, but I don't know how to get around that. My problem is that I have no known end pattern, except the start of another variable pattern.

Does anyone know how I might be able to accomplish this task? Thanks for any information you can provide!

adrian.webb
  • 69
  • 2
  • 5

0 Answers0