learn bash: dynamic variable with condition