Redireccionamiento estándar inputoutput en Windows PowerShell


¿Cuál es la sintaxis necesaria para redirigir la entrada/salida estándar en Windows PowerShell?

En Unix, usamos:

$./program <input.txt >output.txt

¿Cómo puedo ejecutar la misma tarea en PowerShell?

Author: JasonMArcher, 2012-07-12

2 answers

No puede conectar un archivo directamente a stdin, pero aún puede acceder a stdin.

Get-Content input.txt | ./program > output.txt
 31
Author: JasonMArcher,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-08-03 02:33:58

Para la redirección de salida puede utilizar:

  command >  filename      Redirect command output to a file (overwrite)

  command >> filename      APPEND into a file

  command 2> filename      Redirect Errors 

La redirección de entrada funciona de una manera diferente. Por ejemplo, consulte este Cmdlet http://technet.microsoft.com/en-us/library/ee176843.aspx

 6
Author: iSamnium,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-07-12 08:30:10