|
Answer» After many years USING AmigaOS and other unix-like SHELLS I've now started using PowerShell 1.0 for Windows but I have a problem. I can't find infos about the typical unix-like equivalent to run a command and process its output from within a longer command line... This simple example makes "Echo" display the result of a "date" command with Unix shells and AmigaOS SHELL: Echo `date` In other words it will run "date" and then "echo" will print the output from that command. All in one go.
How does this work with PowerShell? Is there a way to do the same thing?It is easy to do in NT family batch language using FOR
FOR /F "delims=" %%D in ('date /t') do echo %%D
Note
- the single quotes
- that Windows date command waits for input, WHEREAS date /t displays the current date
- you have the variable %date% so you can just echo %date%, but I REALISE that was just an example.
I think you might wait a while for a Powershell answer...
Thank you Salmon Trout, I knew the FOR thing...
I've found by myself the solution in PowerShell and is simple as that of the unix-like shells: echo "Today is $(date)" It will run the 'date' command but its ouput will be passed to 'echo'.
|