2012-07-12 16 views
20

में मानक इनपुट \ आउटपुट को पुनर्निर्देशित करना Windows PowerShell पर मानक इनपुट/आउटपुट को पुनर्निर्देशित करने के लिए आवश्यक वाक्यविन्यास क्या है?विंडोज पावरशेल

यूनिक्स पर, हम का उपयोग करें:

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

मैं कैसे PowerShell में एक ही कार्य को निष्पादित करते हैं?

+0

संबंधित: http://stackoverflow.com/questions/16098366/can-i-send-some-text-to-the-stdin-of-an-active-process-under-windows – eckes

उत्तर

25

आप फ़ाइल को सीधे स्टडीन पर नहीं लगा सकते हैं, लेकिन आप अभी भी stdin तक पहुंच सकते हैं।

Get-Content input.txt | ./program > output.txt 
+0

यह पढ़ता स्मृति में संपूर्ण 'input.txt' फ़ाइल। सावधान रहें यदि 'input.txt' बड़ा हो सकता है। –

6

उत्पादन पुनर्निर्देशन के लिए आप उपयोग कर सकते हैं:

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

    command >> filename  APPEND into a file 

    command 2> filename  Redirect Errors 

इनपुट पुनर्निर्देशन एक अलग तरह से काम करता है। उदाहरण के लिए यह सीएमडीलेट http://technet.microsoft.com/en-us/library/ee176843.aspx

संबंधित मुद्दे