Commands / Files

Get-Content

Read a text file

beginner Files Aliases gccattype

Get-Content
 Get-Content -Path .\notes.txt
Works on
WindowsLinuxmacOS
PowerShell
5.1 and later
Reference
Microsoft Learn: Get-Content

What you'll see

Buy milk
Call the printer company
Back up the laptop on Friday

Reads a file as an array of lines. -TotalCount 20 is the first 20 lines. -Tail 20 is the last 20.

Do not use this on huge binaries. For CSV, prefer Import-Csv.

Try this

Get-Content -Path .\notes.txt -Tail 10

Coming from another shell

ShellWhat you might type
bash / zshcat notes.txt
cmd.exetype notes.txt

More in From bash and From cmd.

Related commands