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 :-(
ok problem fixed
for /f "tokens=*" %%a in ('awk "/GPSID/ {print $3}" gora.RTK ') do set var=%%a
awk "BEGIN {printf \"GPSID : \" }" >out.txt
echo %var% >>out.txt
This code basicly does what I wanted to do.
You are great Thanks !!!!!
If you need to recurse through the output of the command, you can use for /f
. Something like:
for /f "usebackq" %%L in (`awk '/GPSID/ {print $3}' gora.RTK`) do (
awk 'BEGIN {printf "Numer seryjny : " %%L,$1}' >> out.txt
)
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.