Home > Net >  How to use powershell to get the next word, in this case it's number, from a specific word in t
How to use powershell to get the next word, in this case it's number, from a specific word in t

Time:10-16

How to use powershell to echo the next word, in this case it's number, from a specific word in the output

For example this command

powershell echo "$(chia wallet show -w standard_wallet | Select-String -Pattern "Spendable:")

Gives this line that has the specific word "Spendable:" from the output

   -Spendable:             0.255502536372 xch (255502536372 mojo)

How do I get only the next word in this line which is 0.255502536372 in this case

CodePudding user response:

You can use a Positive Lookbehind to match for the requested.

powershell "(chia wallet show -w standard_wallet | Select-String -Pattern '(?<=Spendable:\s ).\.\d ').Matches.Value"

RegEx Demo

  • Related