Alex Rivera | Logout

What's the cmd/PowerShell equivalent of back tick on Bash?

Asked 2009-01-11T23:40:23.260
88

Redirecting command output:

For example:

echo "Foo `./print_5_As.rb`"

would echo "Foo AAAAA"

Edit
Report

1 Answer

26

In CMD.EXE there is no direct equivalent. But you can use the FOR command to achieve what you want.

Do something like the following:

FOR /F "usebackq" %x IN (`./print_5_As.rb`) DO @echo Foo %x

or

FOR /F %x IN ('"./print_5_As.rb"') DO @echo Foo %x

You might need to set delimiter to something else than the default, depending on how the output looks and how you want to use it. More details available in the FOR documentation at https://technet.microsoft.com/en-us/library/bb490909.aspx

answered 2009-01-12T00:13:24.803

Your Answer