cat — Print file contents to standard output across all 5 shells
Equivalents in every shell
Worked examples
Show a file
cat README.mdGet-Content README.mdtype README.mdConcatenate two files into a third
cat a.txt b.txt > c.txtGet-Content a.txt, b.txt | Set-Content c.txtcopy a.txt+b.txt c.txtFollow / tail a growing file
tail -f app.logGet-Content app.log -Wait -Tail 10powershell Get-Content app.log -WaitGotchas
- `Get-Content` returns an array of strings — useful in pipelines, but slower than `[System.IO.File]::ReadAllText` for huge files.
- cmd `type` cannot follow / tail; for `tail -f` behavior on Windows use PowerShell `Get-Content -Wait`.
WSL & PowerShell Core notes
Common tasks using cat
- Count lines in a file
Get the line count of one or more files, recursively or in a single command.
- Count words in a file
Count the number of whitespace-separated words in a file or piped text.
- Decode a base64 string
Convert a base64-encoded string back to its original bytes — for inspecting JWT payloads, decoding kubectl secret values, reading basic-auth headers, and pulling binary out of YAML / JSON configs.
- Encode a string to base64
Convert a string (or file) to its base64 representation — for HTTP basic auth headers, JWT payloads, embedded credentials in YAML, or any text-only transport of binary.
- Format (pretty-print) JSON from a shell
Pretty-print a JSON blob from a curl response, log line, or config file — for human-readable inspection or diffing.
- Loop over lines in a file
Iterate through a file one line at a time and run a command per line — for batch processing a hostnames list, replaying a SQL script line-by-line, or reacting to log lines.
- Merge multiple files into one
Concatenate the contents of several files into a single output file.
- Watch a file for changes
React when a file is modified — for tail-style log viewing, hot-reload tooling, or "wait until this completes" automation.