One of the most basic operations of the file is reading content from a file. So far, we have been reading content from file as a block of text. The PowerShell cmdlet for this operation is Get-Content. And it works a little different than expected. This recipe is aimed at explaining how different it is.
The task for this recipe is simple. You must display details of the file on the screen, as follows:
- Show the details of a file
- Read the first seven lines from the file
- Read the last five lines of the file
- Read content from the 11th to the 13th line of the file
- Display the number of characters, words, and lines in the file
- Import the contents of the file into a variable