Having the following content in a file:
VARIABLE1="Value1" VARIABLE2="Value2" VARIABLE3="Value3"
I need a script that outputs the following:
Content of VARIABLE1 is Value1 Content of VARIABLE2 is Value2 Content of VARIABLE3 is Value3
Any ideas?
conf file in Linux, first locate it in the file system. Most often, the dhclient. conf file will be located in the /etc or /etc/DHCP directory. Once you find the file, open it with your favorite command-line editor.
The /etc/bashrc file might be referred to in /etc/profile or in individual user shell initialization files. The source contains sample bashrc files, or you might find a copy in /usr/share/doc/bash-2.05b/startup-files.
Since your config file is a valid shell script, you can source it into your current shell:
. config_file echo "Content of VARIABLE1 is $VARIABLE1" echo "Content of VARIABLE2 is $VARIABLE2" echo "Content of VARIABLE3 is $VARIABLE3"
Slightly DRYer, but trickier
. config_file for var in VARIABLE1 VARIABLE2 VARIABLE3; do echo "Content of $var is ${!var}" done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With