Skip to content
NewBun 1.4.5 is out. Release notes
AphrodyBun

Guides · File System

Write a file to stdout

Print the contents of a file to standard output with Bun.write(Bun.stdout, file), like the Unix cat command.

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().