Windows powershell get first / last 100 lines of txt file
Updated: 1th July 2020
Tags: windows powershell
Windows powershell get first 100 lines of txt file
Get-content -head 100 .\myfile.log
Windows powershell get first 100 lines of txt file and save it to file
Get-content -head 100 .\myfile.log | Out-File -FilePath .\myfile_first_100.log
Windows powershell get last 100 lines of txt file
Get-content -tail 100 .\myfile.log
Windows powershell get last 100 lines of txt file and save it to file
Get-content -tail 100 .\myfile.log | Out-File -FilePath .\myfile_last_100.log
Simplified syntax
Get-content -head 100 myfile.log > myfile_first_100.log
Get-content -tail 100 myfile.log > myfile_last_100.log