Display first n lines, lines in middle or last n lines of a file with powershell.
Sometimes we need some specific content for a file, may be a version number , config details that lies in a specific file or config file.
We will be using the PowerShell cmdlets to achieve this.
Create a file with 10 lines with 1..10 and name it as file.txt
Now we use the cmdlet Get-content and get the required output using select.
Getting first 5 lines
Getting last 5 lines
Skipping first 3 lines and displaying rest..
Display some line in the middle say line 5,
This could be a useful approach to get the data fast across infrastructure with the help of PS remoting.