Extracting columns from text file using PowerShell
问题 I have to extract columns from a text file explained in this post: Extracting columns from text file using Perl one-liner: similar to Unix cut but I have to do this also in a Windows Server 2008 which does not have Perl installed. How could I do this using PowerShell? Any ideas or resources? I'm PowerShell noob... 回答1: Try this: Get-Content test.txt | Foreach {($_ -split '\s+',4)[0..2]} And if you want the data in those columns printed on the same line: Get-Content test.txt | Foreach {"$(($_