Home bash: create a variable name containing another variable
Reply: 0

bash: create a variable name containing another variable

user638
1#
user638 Published in May 21, 2018, 3:11 am

I have to create multiple variable while reading the file in bash. These variables need to have a dynamic name as per the content of file. E.g:

File content:

abc: 20
1 apple a day
abc: 40
1 keeps the doctor away

now i have to create variables as:

day_20_id = 1
day_20_fruit = apple
away_40_id = 1
away_40_who = doctor

it would be like in all variable names, only the the value of $abc will be updated and the value of the variable will be as per the file content.

Can somebody help me out to figure out how to achieve this.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30636 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO