I need to grep the output from a command, there will be multiple lines for each expression, and use that information in variables for the rest of my script. The grep -E is the easy part. I read an article about putting a single result into a variable, but this is a little more complicated (at least for me). Here is sample output from the grep.
bppllist -allpolicies -U | grep -E "Policy Name:|Policy Type:"
Outputs:
Policy Name: AAAAA Policy Type: NBU-Catalog Policy Name: BBBBB Policy Type: MS-Windows Policy Name: CCCCC Policy Type: MS-SQL-Server
What I need to do is capture the Name and Type from each iteration to use for further actions. Some sort of a for or while loop I would guess. Would it be easier to output the grep results to a file then read it in?? Iām open to any options.
For this example, I would want to look at the Type first, and if it meets my criteria, run a command for Name
if [$TYPE = "MS-Windows"]
then
<command > $NAME
fi
Thanks in advance
John