cat
Files
SKILL.mdagentsreferences
Install
Install the containing plugin
/plugin install shared-skills@llm-skills
Invoke this skill after installation
/shared-skills:cat
This skill is bundled inside shared-skills. Install the plugin once, then Claude Code can use any of its included skills. Browse the full plugin repository at github.com/alisonaquinas/llm-shared-skills.
SKILL.md
name: cat description: > Concatenate and display file contents with cat for reading files, combining multiple files, writing heredoc content, and feeding file data into pipelines. Use when the agent needs to print a file's contents to stdout, join several files into one, pipe a file into another command, or inspect a short file quickly.
cat
Concatenate files and print their contents to standard output.
Quick Start
- Verify availability:
cat --version(GNU) orman cat - Display a file:
cat file.txt - Concatenate files:
cat a.txt b.txt > combined.txt
Intent Router
references/cheatsheet.md— Display, concatenate, number lines, show non-printing characters, file writing via heredocreferences/advanced-usage.md— Combining with pipelines, heredoc patterns, binary file awareness, tac for reversereferences/troubleshooting.md— Binary content warnings, large file pitfalls, useless use of cat, encoding issues
Core Workflow
- Use
cat filefor quick inspection of short files - Use
cat a b c > outto concatenate multiple files in order - Pipe
cat file | commandonly when the command does not accept a filename argument — many tools accept files directly, makingcatunnecessary - Use
cat -Aorcat -vto reveal non-printing characters when diagnosing encoding or line-ending issues - Use
cat -nto number lines for reference when discussing file content
Quick Command Reference
cat file.txt # Display file contents
cat a.txt b.txt # Concatenate and display two files
cat a.txt b.txt > combined.txt # Concatenate into a new file
cat >> file.txt # Append stdin to a file (Ctrl-D to end)
cat -n file.txt # Number all output lines
cat -b file.txt # Number non-blank lines only
cat -A file.txt # Show all: mark tabs (^I), line ends ($)
cat -v file.txt # Show non-printing characters
cat -s file.txt # Squeeze multiple blank lines into one
tac file.txt # Print lines in reverse order
cat /dev/null > file.txt # Truncate a file to zero bytes
man cat # Full manual
Safety Notes
| Area | Guardrail |
|---|---|
Overwrite with > | cat a > b overwrites b silently. Use >> to append. Confirm destination path before redirecting. |
| Binary files | cat will send raw binary bytes to the terminal, which can corrupt terminal state. Check with file first; use xxd or hexdump for binary inspection. |
| Large files | cat on a large file floods the terminal. Use head, tail, less, or grep for targeted inspection. |
| Useless use of cat | cat file | grep pattern is better written as grep pattern file. Eliminating unnecessary cat reduces process overhead and clarifies intent. |
| Truncation via redirect | cat /dev/null > file or > file immediately truncates file to zero bytes. This is irreversible without a backup. |
Source Policy
- Treat
man catandcat --helpas runtime truth. GNU and BSDcatshare most flags. - Avoid "useless use of cat" — pass filenames directly to commands that accept them (
grep,sort,wc, etc.). - Use
lessorbatfor interactive browsing of files longer than a screenful.
See Also
$echofor printing literal strings rather than file contentsless/morefor paginated file viewinghead/tailfor reading the start or end of a filetacfor reversed line order output