# Run a Shell Command (/docs/guides/runtime/shell)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 207 · updated: 2026-07-28 -->
Related: [Delete directories](/docs/guides/runtime/delete-directory.md), [Delete files](/docs/guides/runtime/delete-file.md), [Import a HTML file as text](/docs/guides/runtime/import-html.md), [Import a JSON file](/docs/guides/runtime/import-json.md), [Import a JSON5 file](/docs/guides/runtime/import-json5.md), [Import a TOML file](/docs/guides/runtime/import-toml.md)

Bun Shell is a cross-platform bash-like shell built into Bun.

It runs shell commands from JavaScript and TypeScript. To get started, import the `$` function from the `bun` package.

```ts foo.ts icon="/icons/typescript.svg"
import { $ } from "bun";

await $`echo Hello, world!`; // => "Hello, world!"
```

***

The `$` function is a tagged template literal that runs the command and returns a promise that resolves with the command's output.

```ts foo.ts icon="/icons/typescript.svg"
import { $ } from "bun";

const output = await $`ls -l`.text();
console.log(output);
```

***

To iterate over each line of the output, use the `lines` method.

```ts foo.ts icon="/icons/typescript.svg"
import { $ } from "bun";

for await (const line of $`ls -l`.lines()) {
  console.log(line);
}
```

***

See [Bun Shell](/runtime/shell).
