Wednesday, January 27, 2010

Backticks for windows. (almost)

In Linux, or more specifically in the sh and bash shells, backticks " ` " execute a command and insert the results into a command. I found a great trick to do almost the same thing over at PcReview

This snippet will save the hostname of a PC to an environment variable.


for /f "delims=" %%A in ('hostname') do set hostname=%%A
echo %hostname%


It loops over the output and keeps setting the variable. Cool.

No comments: