# Print a Multi-Line String in Bash with printf

> Use printf instead of echo to reliably print multi-line strings with newline escape sequences in Bash, as not all echo versions support the -e flag

**URL:** https://sentry.io/answers/print-a-multi-line-string-in-bash/

---

## The Problem

How can I print a string with multiple lines in Bash?

```bash
echo "Hello\nworld"
```

produces:

```
Hello\nworld
```

## The Solution

On some systems, `echo` includes a `-e` parameter, which will enable escape sequences like `\n`. So this:

```bash
echo -e "Hello\nworld"
```

should produce:

```
Hello
world
```

However, not all versions of `echo` support this flag. A more reliable and portable alternative is to use `printf` instead of `echo`:

```bash
printf "Hello\nworld"
```

will produce:

```
Hello
world
```

You can read more about `printf` by typing `man printf` into your terminal.

---

*Source: [sentry.io/answers/print-a-multi-line-string-in-bash/](https://sentry.io/answers/print-a-multi-line-string-in-bash/)*
