I'm currently stuck on how to do the following:
I have a settings file that looks like this:
USER_ID=12
ROLE=admin
STARTED=10/20/2010
...
I need to access the role and map the role to one of the variables in the script below. After I will use that variable to call open a doc with the correct name.
test.sh
#!/bin/sh
ADMIN=master_doc
STAFF=staff_doc
GUEST=welcome_doc
echo "accessing role type"
cd /setting
#open `settings` file to access role?
#call correct service
#chmod 555 master_doc.service
Is there a way to interpolate strings using bash like there is in javascript? Also, I'm guessing I would need to traverse through the settings file to access role?
$admin, so what are you trying to accomplish exactly? Ifadmin = master_docis supposed to be assignment, the spaces shouldn't be there. Please edit to clarify.settings, use$roleas an indirect reference to$admin, i.e.master_doc, then turn that into a string,master_doc.service. I'll write you answer.sh, notbash. Also you did not define the syntax of your settings file. The example you povided, would be valid syntax in both sh and in bash, so asource settingswould be enough to read the variables in your concrete example.