PowerTip: Use PowerShell to return first two lines of file

Doctor Scripto

Summary: Learn how to use Windows PowerShell to return the first two lines of a text file.

Hey, Scripting Guy! Question How can I use Windows PowerShell to easily return the first two lines of a text file?

Hey, Scripting Guy! Answer Use the Get-Content cmdlet and specify the TotalCount parameter. In this example, TotalCount is set
           to 2 and the file is named AMoreComplete.txt:

Get-Content ‘C:\fso\AMoreComplete.txt’ -TotalCount 2

0 comments

Discussion is closed.

Feedback usabilla icon