I have the following setup:
NODEX="sn1"
varname="${NODEX}_payTimestamp"
echo "${!varname}"
> sn1_payTimestamp
How can I set a value to the variable “sn1_payTimestamp”?
Something like that?
${!varname}=$(date --utc +%Y%m%d_%H%M%SZ);
Thx in advance
Update
associative arrays seem to be the best solution. Is there a good way to store them into and read them from a text file? This is why I intended to use that “variable variable names”.
printforechoor whatever plus redirection to write them, and you can usemapfileto read them. or use a while-read loop. If your requirements are complex or if performance is important then bash is the wrong language for the job, look into using awk or perl or python or something. Shell is not a good language for processing data. It is great at coordinating other programs to process data, but terrible at doing the processing itself. It's the wrong tool for that job.