Wizard
Wizard

Reputation: 22143

Combine options and variable inline with builtin `read`

Suppose such a mininal example

    $ read -p "Enter a numeral: "
    Enter a numeral: 4
    $ echo $REPLY
    4

In the above, there's no variable listed, REPLY be assigned to input automatically.

I'd like to list a variale like:

    $ read  foo -p "Enter a numeral: "
    4
    -bash: read: `-p': not a valid identifier

How to achieve it not invoking echo command?

Upvotes: 1

Views: 20

Answers (1)

kyodev
kyodev

Reputation: 583

read -p "Enter a numeral: " foo

variable to assign after options

Upvotes: 2

Related Questions