How it works...
The first task is relatively simple. It shows you the details about the file. Think of this as peeking into the file properties. If you would like more details, pipe the first line of the command to Select-Object *.
The second line is very important. The ReadCount parameter instructs Get-Content to read n lines in a shot, and pass it along the pipeline. In our case, note how we have used -ReadCount 7 | Select-Object -First 1 to read the first seven lines. In this case, Get-Content read the first seven lines of the file as a single block.
To read the last five lines of the file, we use the Tail parameter. However, in this case, the number of elements (lines) is retained; the imported content is an array of five strings, not ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access