Link to home
Start Free TrialLog in
Avatar of pvinodp
pvinodp

asked on

source command inside a shell script does not work if a key contains multiple values

I have a file, interfaceDetail , who content are as below:

AP=Northbound
AC=Southbound
RADIUS=Northbound

Now when i change interfaceDetail's content to below:

AP=Northbound
AC=Southbound
RADIUS=Southbound Northbound

i get the error " line 3: Northbound: command not found"  from all places where i try to source interfaceDetail .
How do i have multiple values to my key in a source file?
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can you explain what you mean by "multiple values" how you are going to use them?

If you want just to assign the values to the variable then just put " or ' around the values
try:
AP=Northbound
AC=Southbound
RADIUS="$AP $AC"
#   Or ...
 set -A RADIUS $AP $AC

Open in new window

In Bash you can do something like below

#!/bin/bash
RADIUS=( Southbound Northbound )

for radius in ${RADIUS[@]}
    do
    # DO whatever you want to do here
    echo $radius
    done
Avatar of pvinodp
pvinodp

ASKER

thanks for your quick response