Is there any way to accomplish the following in one stroke using Bash?
my_var=${$(grep -E '^setting_1' /settings.conf):-default_setting1}
As opposed to:
my_var=$(grep -E '^setting_1' /settings.conf); my_var=${my_var:-default_setting}
Is there any way to accomplish the following in one stroke using Bash?
As opposed to:
|
||||
|
You can output the default if the grep fails:
Note that you didn't close the quotes (and without the file argument, grep will filter stdin). |
|||||
|