Get values from property file using bash
Hi guys,
I am a newbie to bash programming. I am trying to run a 'for' loop by reading values from a property file. The values inside the file are similar to below, hosts=<user1>@<server1>,<user2>@<server2>,<user3>@<server3>...... I would like to run a for loop for all the servers (1,2,3..etc). For that, I need to get the list from the file first and this is where I am facing difficulty. This list wont be static and keeps changing. So, I need my script to get the server list whenever I run the script My final goal is to do something like below: for i in <get-server-list-from-file> do some commands done |
Code:
#!/bin/bash |
If you have some control over how the data is entered in the property file, namely single quotes around the items right of the equal sign, you could do the following:
Code:
$ cat property.file |
Thank you so much catkin and grail.... both of your codes worked for me!
|
Here's the mechanics of a similar process I am using to write my own "mass scp" script.
Code:
CONF=/home/jj/.ssh/c9 Some resources: http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html http://www.tldp.org/LDP/Bash-Beginne...tml/index.html http://www.gnu.org/software/bash/man...ode/index.html http://www.grymoire.com/Unix/Sh.html http://tldp.org/LDP/abs/abs-guide.pdf http://www.tldp.org/LDP/abs/html/ http://mywiki.wooledge.org/BashFAQ http://mywiki.wooledge.org/BashPitfalls http://rute.2038bug.com/index.html.gz http://bashscripts.org/forum/ |
Quote:
|
All times are GMT -5. The time now is 03:24 PM. |