Comma Delimited Output w/ egrep

Hi all,

I have an input file that I am pulling out certain phases using the following commands:

cat /nodes.txt | egrep -e 'OSVersion|PrimaryNodeName'

Currently the output looks like this:

OSVersion - 5.0
PrimaryNodeName - serverA
OSVersion - 5.0
PrimaryNodeName - serverB
OSVersion - 5.0
PrimaryNodeName - serverC

I would like to comma delimit the output either between the OSVersion - 5.0 and PrimaryNodeName or after PrimaryNodeName, so that I can export to Excel and end up with OSVersion - 5.0 in one column and PrimaryNodeName in a second column.

So my hope was to have the output look something like this:

OSVersion - 5.0
PrimaryNodeName - serverA,
OSVersion - 5.0
PrimaryNodeName - serverB,
OSVersion - 5.0
PrimaryNodeName - serverC,

Apprecaite any direction that could be provide.

Thanks

try this to get the comma between OSversion and PromaryNodeName ...

awk '/OSVersion/ {print $0","} /PrimaryNodeName/' /nodes.txt

or this to get the comma only after PrimaryNodeName ...

awk '/OSVersion/ /PrimaryNodeName/ {print $0","}' /nodes.txt

or this to get the commas all over ...

awk '/OSVersion/ {print $0","} /PrimaryNodeName/ {print $0","}' /nodes.txt

Thanks for the tips, and they performed exactly what I asked for, however I quickly realized that I trying to perform the wrong task.

I do appreciate you time and response. I am going to open a new thread for what I think I really do need to accomplish.

THanks again.