A minimal implementation of the Unix cat command in raw C with zero library dependencies for macOS ARM64. All system calls are made via inline assembly (svc #0x80), making this an educational project for learning low-level systems programming.
make # Build all milestones + cat
make cat # Build only the final cat implementation./cat [FILE...] # Concatenate files to stdoutRead from stdin:
echo "Hello, world!" | ./catDisplay a single file:
./cat /etc/hostsConcatenate multiple files:
./cat file1.txt file2.txt file3.txtMix files and stdin (use - for stdin):
echo "middle content" | ./cat header.txt - footer.txtError handling (continues on error):
./cat valid.txt /nonexistent/file.txt another.txt
# Prints valid.txt, shows error for nonexistent file, then prints another.txtPerformance tuning (custom buffer size):
cc -nostdlib -e __start -O2 -lSystem -DBUF_SIZE=16384 -o cat cat.c- ✅ Read from stdin (no arguments or
-argument) - ✅ Read and concatenate multiple files
- ✅ Error handling with messages to stderr
- ✅ Continues processing remaining files after errors
- ✅ Configurable buffer size (default 8192 bytes)
- ✅ Zero external dependencies (no libc, raw syscalls)
This project includes 7 incremental milestones (milestones/m1_exit.c through milestones/m7_errors.c), each teaching a specific systems programming concept. See docs/plan.md for the full learning roadmap.