I'm creating a bash script for screen management and want 开发者_如何学Goto pull variables from a config file formatted like so:
[s=sample1]
FOLDER=folder/right/here
COMMAND=python script.py
[i=irssi]
COMMAND=irssi
BOOT
"FOLDER"
, "COMMAND"
, and "BOOT"
would be optional. "[x=y]"
would be required, where "x"
is a single lowercase letter.
I'd like for this sample to be parsed into something like:
NAME[0]="sample1"
SHORT[0]="s"
FOLDER[0]="folder/right/here"
COMMAND[0]="python script.py"
NAME[1]="irssi"
SHORT[1]="i"
BOOT[1]="1"
If you really need to parse ini-styled config files in bash, have a look at this link. Else, as others have pointed out, just place the variables in a file and source it...
精彩评论