1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

rc.conf + rc Script ==> get all related vars

Discussion in 'Userland Programming and Scripting' started by Leander, Apr 29, 2012.

  1. Leander

    Leander Member

    Messages:
    180
    Thanks Received:
    2
    Hi there,

    I want to write a rc script. My rc.conf should hold information for it in following format:

    Code:
    md_enable="YES"
    md_file_md0="/path/to/file-0"
    md_file_md1="/path/to/file-1"
    md_file_md2="/path/to/file-2"


    Now I want something like this in my rc start script to find out about all "md_file_md" related variables:

    Code:
    for FILE in $md_file_md*; do
        echo $FILE
    done


    Obviuosly I could write something by the help of sed / awk to filter for md0, md1, md2, md[n] in rc.conf file ... but I was hoping the rc framework has somthing like this already? Or is there any better ideas of how to solve this easier?

    Thanks
     
  2. graudeejs

    graudeejs Well-Known Member

    Messages:
    4,594
    Thanks Received:
    633
    Why not to set
    Code:
    md_files="/path/to/file-0 /path/to/file-1 /path/to/file-2"
    

    ?
     
  3. Leander

    Leander Member

    Messages:
    180
    Thanks Received:
    2
    Thanks for your input. I thought about such a solution already but the issue is that this method would not relate md dev number with file definition ... So it is not really usable for my needs.
     
  4. Leander

    Leander Member

    Messages:
    180
    Thanks Received:
    2