1

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

  • Your code does not work for me. first its missing a ' " ' at the end. please fix the code that you pasted. – wonderwall Oct 15 '22 at 04:20
  • It works on my command prompt, not sure how to fix it. Here is the result ```C:\Users\kuy>powershell echo "$(chia wallet show -w standard_wallet | Select-String -Pattern "Spendable:")``` I typed it like that and it gives this result `-Spendable: 0.266388243374 xch (266388243374 mojo)` – God of Money Oct 15 '22 at 05:14
  • In powershell this one gives the same output ```PS C:\Users\kuy> powershell echo '"$(chia wallet show -w standard_wallet | Select-String -Pattern "Spendable")'``` of `-Spendable: 0.266388243374 xch (266388243374 mojo) PS C:\Users\kuy>` – God of Money Oct 15 '22 at 05:44
  • In your post you did not add single quote in your comment you added single quotes. – wonderwall Oct 16 '22 at 14:31

1 Answers1

0

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