Languages
[Edit]
EN

Bash - read variable with default value

6 points
Created by:
Maryamcc
511

In this short article we would like to show how in Bash set default value for data read from terminal if data was not typed.

Quick solution:

Where: admin word should be changed to desired value.

or with message: 

 

Default value from variable

Edit

This section shows how to store default value in variable.

Alternative solutions

Edit

In this section we want to show how to assign default value with test command.

 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Bash

Bash - read variable with default value
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join