Runtime
Bundler
Package Manager
Test Runner
Guides
Reference
Blog
Install Bun
Guides File System

Write a file to stdout

Bun exposes stdout as a BunFile with the Bun.stdout property. Pass it as the destination to Bun.write().

The following code writes a file to stdout, like the Unix cat command.

cat.ts
const path = "/path/to/file.txt";
const file = Bun.file(path);
await Bun.write(Bun.stdout, file);

See Bun.write().

On this page

No Headings