How can I inspect a small text file from the command line?
Quick answer
In Bash, run cat filename.txt to display a named file in the terminal. [S1] In PowerShell, run Get-Content -Path filename.txt; it reads file content line by line for display. [S2] Replace filename.txt with your file’s name or path. These examples are for inspecting content, not editing it; avoid using separate commands intended to write or change file contents.
The question, the details, the next step.
A practical checklist
Identify whether you are using Bash or PowerShell.
Replace the sample filename with the file’s name or path.
Use
catin Bash orGet-Content -Pathin PowerShell to display it.For a PowerShell excerpt, use
-TotalCountor-Tailwith a line count.If the command reports an error, check the filename and path; avoid commands intended to write or change content.
A few more useful answers
Does `cat` edit the file?
The GNU Coreutils reference describes cat as copying a named file’s contents to standard output. That is display behavior, not an edit to the input file. [S1]
Can PowerShell show only a few lines?
Yes. The PowerShell 7.3 reference documents -TotalCount for a beginning excerpt and -Tail for an ending excerpt. [S2]
Sources
References used for this guide.
- [S1] GNU Coreutils 9.11 manual: cat — Concatenate and write files gnu.org · Checked
- [S2] PowerShell 7.3 Get-Content reference learn.microsoft.com · Checked
