S
S
Sergey Ch2020-05-21 15:33:59
bash
Sergey Ch, 2020-05-21 15:33:59

How to organize the output of a variable declared earlier?

Probably a stupid question, but somehow I have never come across this before and I don’t understand how to formulate it.
Let's say we have some variables, let's say environment variables:
VAR_NAME[0-9]=VAL
We want to make a function to display the name of the variable and its value:

print_var_val(){
   echo "$1=$($1)"   #  ?? Чем заменить эту конструкцию   $($1) ??
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynn "Coffee Man", 2020-05-21
@ZooMik

https://www.gnu.org/savannah-checkouts/gnu/bash/ma...

print_var_val() {
   echo "$1=${!1}"
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question