N
N
nihi1ist2021-03-15 11:35:35
linux
nihi1ist, 2021-03-15 11:35:35

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.

How do I do it
read -e -p "
Enter agent port. Default: 8080 " agent_p

Could you tell me how to implement such a dialogue?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xibir, 2021-03-15
@nihi1ist

def=8080
read -e -p "
Enter agent port. Default: $def " agent_p
 || agent_p=$def

V
Victor Taran, 2021-03-15
@shambler81

https://habr.com/ru/company/ruvds/blog/328436/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question