Windows Powershell Piping and redirection _powershell

Source: Internet
Author: User

Pipeline

The output of the previous command as the input to the next command.


PowerShell Pipeline

For example, get all the file information for the current directory through LS, and then by sort-descending the file information in descending order of name, and finally format the name and mode of the sorted file as table output.

PS c:\pstest> ls | Sort-descending Name | Format-table name,mode

Name                            Mode
----                            ----
d.txt-a---c.txt-a                            ---
b.txt -A                            ---
ABC                             d----
a.txt-a                            ---

redirect

Save the output of the command to the file, ' > ' for Overwrite, ' >> ' append.

PS c:\pstest> "Powershell Routing" >test.txt
PS c:\pstest> get-content. \test.txt Powershell routing<
C3/>ps c:\pstest> "Powershell Routing" >>test.txt
PS c:\pstest> "Powershell Routing" >>test.txt< C5/>ps c:\pstest> "Powershell Routing" >>test.txt
PS c:\pstest> "Powershell Routing" >>test.txt< C7/>ps c:\pstest> "Powershell Routing" >>test.txt PS c:pstest\> get-content. \test.txt Powershell
Routing
Powershell Routing
Powershell Routing
Powershell Routing Powershell Routing Powershell Routing
PS c:\pstest>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.