0

我正在尝试从 Windows 7 DOS shell 中动态创建一个 bash 命令文件:

:: inside the .BAT file ..
:: check we are in the right directory
echo pwd > command.txt
:: get the shell to echo its environment variables
:: !!!! How do I get around this ... ?
echo echo $PWD

我认为用 ^ (插入符号)作为第二个 echo 命令的前缀会起作用,但不行。解决办法是什么?

4

2 回答 2

3

我刚试过

@echo 回声 %TMP%

返回

回声 C:\Users\Spike\AppData\Local\Temp

我认为问题不在于回声,而在于 $PWD。%% 是 $ 的 DOS。

于 2010-03-09T23:18:57.850 回答
2

这适用于我在 Windows XP 上,

@echo off
:: inside the .BAT file ..
:: check we are in the right directory
echo pwd > command.txt
:: get the shell to echo its environment variables
:: !!!! How do I get around this ... ?
echo echo ^$PWD >>command.txt

输出

C:\test>test.bat

C:\test>more command.txt
pwd
echo $PWD
于 2010-03-09T23:46:46.243 回答