ASSIGN win XP 命令行输出到变量
我想将以下脚本从 linux shell 翻译为 Windows XP shell
GPSID=$(awk '/GPSID/ {print $3}' gora.RTK )
awk -v variable=${GPSID} 'BEGIN {printf "Numer seryjny : " variable,$1}' >>out.txt
第二行已翻译; 问题在于定义一个包含 Windows 中 shell 输出的变量:-(
i would like to translate a following script from linux shell to Windows XP shell
GPSID=$(awk '/GPSID/ {print $3}' gora.RTK )
awk -v variable=${GPSID} 'BEGIN {printf "Numer seryjny : " variable,$1}' >>out.txt
The second line has been translated; the problem is with defining a variable that contains shell output in windows :-(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好的问题已解决
此代码基本上完成了我想做的事情。
你太棒了谢谢!!!!
ok problem fixed
This code basicly does what I wanted to do.
You are great Thanks !!!!!
如果需要递归查看命令的输出,可以使用
for /f
。 就像是:If you need to recurse through the output of the command, you can use
for /f
. Something like:怎么样...
for /f "tokens=*" %%a in ('echo Hello World') do set var=%%a
注意:在命令行上尝试时使用 %a 而不是 %%a,否则保留它如果在批处理文件中使用,则为 %%a。
其中“echo Hello World”是要捕获其输出的命令,“var”是将存储输出的变量的名称。
How about ...
for /f "tokens=*" %%a in ('echo Hello World') do set var=%%a
NOTE: use %a instead of %%a when trying on the command line else keep it as %%a if using in a batch file.
Where 'echo Hello World' is the command whose output you want to capture and "var" is the name of the variable where the output will be stored.