0

Let me redo my question:

OK, newb here but here is what I am trying to do:

I am trying to write an init script that pulls different config files and pass them into different variables. The END result is to have an init script that can start multiple instances of an application (redis) by pulling different config files.

The directory is

/etc/conf.d

and the files in their are:

foo.conf
bar.conf

Now, here is what I have for the function:

dir=/etc/conf.d
configFiles='ls ${dir}/*'

for ((i=0, j=1; i< ${#configFiles[@]}; i++, j++)); do
   declare "conf$j"="${configFiles[$i]}"
done
echo $conf1
echo $conf2

conf1 will print out as /etc/conf.d/foo.conf conf2 will print out as " " then "/etc/conf.d/foo.conf" then "/etc/conf.d/foo.conf /etc/conf.d/bar.conf"

I need conf2 to equal bar.conf but I also need to abstract naming convention because the names of the conf file could change with our deployment methods.

So, end result is to put this in a function, and call it in the init script to pass the files (e.g. /etc/init.d/program start foo / start bar )

Thank you.

E.Z.
  • 139
  • 2
  • 14
  • 2
    [Don't Parse `ls`](http://mywiki.wooledge.org/ParsingLs). You also have a number of syntax errors, etc. http://shellcheck.net will help you with many of them. – Etan Reisner Sep 22 '15 at 00:40
  • Thanks @EtanReisner! I did not know about shellcheck.net . This is a big help. – E.Z. Sep 22 '15 at 02:53

0 Answers0