Read a variable in bash with a default value

Posted by rmarimon on Stack Overflow See other posts from Stack Overflow or by rmarimon
Published on 2010-04-15T03:41:39Z Indexed on 2010/04/15 3:43 UTC
Read the original article Hit count: 523

Filed under:
|
|

I need to read a value from the terminal in a bash script. I would like to be able to provide a default value that the user can change.

# Please enter your name: Ricardo^

In this script the prompt is "Please enter your name: " the default value is "Ricardo" and the cursor would be after the default value. Is there a way to do this in a bash script?

© Stack Overflow or respective owner

Related posts about bash

Related posts about shell