> ## Documentation Index
> Fetch the complete documentation index at: https://www.1password.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# read

Read the value of the field in 1Password specified by a secret reference.

[Learn more about secret references and query parameters.](/cli/secret-reference-syntax/)

```
op read <reference> [flags]
```

### Flags

```
    --file-mode filemode   Set filemode for the output file. It is ignored without the --out-file flag. (default 0600)
-f, --force                Do not prompt for confirmation.
-n, --no-newline           Do not print a new line after the secret.
-o, --out-file string      Write the secret to a file instead of stdout.
```

### Examples

Print the secret saved in the field `password`, on the item `db`, in the vault
`app-prod`:

```shell theme={null}
op read op://app-prod/db/password
```

Use a secret reference with a query parameter to retrieve a one-time
password:

```shell theme={null}
op read "op://app-prod/db/one-time password?attribute=otp"
```

Use a secret reference with a query parameter to get an SSH key's private
key in the OpenSSH format:

```shell theme={null}
op read "op://app-prod/ssh key/private key?ssh-format=openssh"
```

Save the SSH key found on the item `ssh` in the `server` vault
as a new file `key.pem` on your computer:

```shell theme={null}
op read --out-file ./key.pem op://app-prod/server/ssh/key.pem
```

Use `op read` in a command with secret references in place of plaintext
secrets:

```shell theme={null}
docker login -u $(op read op://prod/docker/username) -p $(op read op://prod/docker/password)
```
