I need to pull the version # out of a Vim script that might look something like:
" some header blah blah
" Version: 0.1
[a bunch of code]
" Version: fake--use only the first version
The expected output is 0.1
. If a Version # doesn't exist, it should return the empty string or something like that.
I'm new to Powershell, so this is what I have so far:
Get-Content somescript.vim -ErrorAction SilentlyContinue |
Select-String '^" Version: (.*)' |
select -First 1 -ExpandProperty Matches |
select -ExpandProperty Groups |
select -Index 1 |
select -ExpandProperty Value
It's just that it feels... kind of verbose. For comparison, here's my *nix version:
perl -ne '/^" Version: (.*)/ && do { print "$1\n"; exit }' somescript.vim 2>/dev/null
Or you could write a similarly concise awk
script
Is there any hope for my Windows version being as concise?