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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try:
AP=Northbound
AC=Southbound
RADIUS="$AP $AC"
# Or ...
set -A RADIUS $AP $AC
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
#!/bin/bash
RADIUS=( Southbound Northbound )
for radius in ${RADIUS[@]}
do
# DO whatever you want to do here
echo $radius
done
ASKER
thanks for your quick response
If you want just to assign the values to the variable then just put " or ' around the values