0

I am new with powershell and I need some help with command.

Here is my data: I am execute "db2 get dbm cfg" command I am getting below output:

Diagnostic data directory path (DIAGPATH) = c:\users\db2admin\

What I am want to return the value after the = sign, the output should look like this c:\users\db2admin\

Here is the command I running to get the data, but I can’t figure out how to get c:\users\db2admin\

db2 get dbm cfg | select-string -Pattern DIAGPATH|? {-not($_ -match “ALT_DIAGPATH”)}

If ther an option to add to above command to print last value after = sign?

2 Answers 2

1

If that's the only line you get from that command, a simple split should do it:

((db2 get dbm cfg) -split ' = ')[1]
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much this is what I was looking work.
0

split on = and select the second result (Since the first result will be everything before the =) like this:

((db2 get dbm cfg | select-string -Pattern DIAGPATH|? {-not($_ -match “ALT_DIAGPATH”)}) -split "= ")[1]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.