Files
2026-08-27 21:09:14 +00:00

20 lines
534 B
Plaintext

---
title: Write a file to stdout
sidebarTitle: Write file to stdout
mode: center
---
Bun exposes `stdout` as a `BunFile` with the `Bun.stdout` property. Pass it as the destination to [`Bun.write()`](/runtime/file-io#writing-files-bun-write).
The following code writes a file to `stdout`, like the Unix `cat` command.
```ts cat.ts icon="/icons/typescript.svg"
const path = "/path/to/file.txt";
const file = Bun.file(path);
await Bun.write(Bun.stdout, file);
```
---
See [`Bun.write()`](/runtime/file-io#writing-files-bun-write).