using shell scripting, want split name variable. suppose in .conf file data this:
ssh.user = root ssh.server = localhost
then want ssh.user in 1 variable , root in variable? should do?
if can live solution doesn't use dots in variable names, use source
(source execute file given argument script):
a file called config
sshuser = root sshserver = localhost
`and script using configuration:
#!/bin/bash source config echo $sshuser
will output
root
several techniques other sourcing explained right here on stackoverflow reading config file shell script
now, fact variables contain dot issue, perhaps technique (using awk
) explained in yet question help: how grab ini value within shell script?
applied case give like
ssshuser=$(awk -f "=" '/ssh.user/ {print $2}' configurationfile)
last potential issue, whitespaces. see here how trim whitespace bash variable?
Comments
Post a Comment