Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Okay, I'm going to get all pedantic here, just to clarify the question.
The OP has a text file with content that looks like a bunch of assignments of values to variables. However, the 'variables' are not really variables until some script that can use that syntax executes it. So the real question is either how to craft a file with the specified content, or how to instantiate the assignments specified in the existing file. There really isn't enough information provided to unambiguously answer the question in either form.
If the OP wants to know how to create a file of the given format, he/she needs to tell us a bit about where the content is supposed to originate.
If the OP wants to instantiate the variables as they are defined in the file, we need to know in what language they are to exist. If we assume they are to become bash variables, then the easy way is to source the file:
Code:
. file.txt
After having done this, the variables will exist with the specified values in that shell. As they are not 'exported', child shells and other processes will not inherit them.
I think the OP is basically looking at a cfg/data file that can be automatically updated by a feeder script, before being used by another script/program ??
Something like
Code:
feeder.sh updates file.txt
prog reads file.txt and processes
feeder is in loop, repeat from top
Almost like ETL: read DB1 then store results; 2nd prog reads store and eg inserts into DB2
Reading between the lines, I would guess that's probably what the OP means. That's still a lot of uncertainty. Still, how are we to have any inkling where the variables and respective values are to come from. Surely the data must exist, somewhere, in some form. We need to know more about where and what it looks like.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.