1、Windows下将某个命令执行结果为单行时,转化为给某个变量的方式如下:
*************************************
REM retrieve the hostname =begin=
hostname > hostname.cnd
for /F %%i in (hostname.cnd) do (
set host=%%i
goto done
)
:done
del hostname.cnd
REM retrieve the hostname =end=
************************************
2、Linux下将某个命令执行结果为单行时,转化为给某个变量的方式如下:
**********************
export host=`hostname`;
**********************
*************************************
REM retrieve the hostname =begin=
hostname > hostname.cnd
for /F %%i in (hostname.cnd) do (
set host=%%i
goto done
)
:done
del hostname.cnd
REM retrieve the hostname =end=
************************************
2、Linux下将某个命令执行结果为单行时,转化为给某个变量的方式如下:
**********************
export host=`hostname`;
**********************