---
title: Exec Command
description: Learn more about the `exec` command in Melos.
---

# Exec Command

<Info>Supports all [Melos filtering](/filters) flags.</Info>

Execute an arbitrary command in each package.

```bash
melos exec
# e.g. melos exec -- pub global run tuneup check
```

The command is executed in a shell. On Windows the shell is `cmd.exe` and on all
other platforms it is `sh`.

If multiple commands are being executed and no further commands should be
executed after a command has failed, connect the commands with `&&`:

```shell
melos exec -- "melos bootstrap && melos run build"
```

It is important to pass multiple commands as a single string to `melos exec`,
otherwise the shell will pass only the first command to `melos exec`.

## concurrency (-c)

Defines the max concurrency value of how many packages will execute the command
in at any one time. Defaults to `5`.

```bash
# Set a 1 concurrency
melos exec -c 1  -- "dart analyze ."
```

## --fail-fast

Whether exec should fail fast and not execute the script in further packages if
the script fails in an individual package. Defaults to `false`.

```bash
# Fail fast
melos exec --fail-fast -- "dart analyze ."
```

## --group-logs

When executing a command in multiple packages concurrently, the output of the
packages is streamed as it is produced, which means the logs of the different
packages are interleaved and hard to follow.

With `--group-logs`, the output of each package is buffered instead and printed
once every package has finished, grouped per package and in the order the
output was produced. Packages in which the command failed are printed last, so
failures are at the end of the log where they are easy to spot. Defaults to
`false`.

The flag only has an effect when the command runs in more than one package with
a concurrency greater than 1. When the command runs in a single package or with
`--concurrency 1`, the output cannot interleave in the first place, so
`--group-logs` is a no-op and the output is streamed as usual.

```bash
# Print the output grouped per package, once all packages have finished
melos exec --group-logs -- "dart analyze ."
```

<Info>
  Since the output is only printed once all packages have finished, nothing is
  printed while the command is running.
</Info>
