Answer the question
In order to leave comments, you need to log in
How to implement default value in read in bash script?
I'm trying to implement a dialog in a bash script that will allow you to enter data. For example: port number. But I also want to implement the ability to continue without entering a value, so that the default value is substituted.
read -e -p "
Enter agent port. Default: 8080 " agent_p
Answer the question
In order to leave comments, you need to log in
def=8080
read -e -p "
Enter agent port. Default: $def " agent_p
|| agent_p=$def
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question