echo - How to print name and version of a tool in cmd in one line? -
i want print version of e.g. packer in cmd. works packer --version
. unfortunately prints version number - not name of tool. case other tools (e.g. virtualbox, etc.), too.
c:\_temp λ packer --version 0.10.1 λ vboxmanage --version 5.1.4r110228
so idea somethink echo packer & packer --version
prints in 2 lines:
c:\_temp λ echo packer & packer --version packer 0.10.1
now, how can print name + version number in 1 line? result looks like:
packer 0.10.1 virtualbox 5.1.4r110228
assign result of version environment variable
for /f %a in ('packer --version') set version=%a
then echo
echo packer %version%
explanation:
- you're looping on output of
packer --version
(there's 1 line though version gets set one) - if need 1 token line can specify eg "tokens=2" second space delimited token.
note: these commands work command line. use in batch file turn %a %%a.
Comments
Post a Comment