Hi,
I have a small doubt. Here is the code snippet for which the output that I'm getting are a bit surprising.
testing.sh
#!/bin/sh
arg_1=$1
echo "arg passed by user is:${arg_1}"
mapping=`grep ${arg_1}= testing.conf | awk -F"=" '{print $2}'`
echo "mapping is $mapping"
key=param_file_$mapping
echo "key:${key}~"
param_file=`grep ${key}= testing.conf | awk -F"=" '{print $2}'`
echo "param file is:${param_file}"
testing.conf
ram=219
param_file_219=/home/testDir
ram_kumar=220
param_file_220=/home/testdir1
Now while running the shell script as
./testing.sh ram I am getting the following output
output
arg passed by user is:ram
mapping is 219
~eyaram_file_219
param file is:
The lines in bold in the output are quite ambiguous.
The desired output should be
arg passed by user is:ram
mapping is 219
key
aram_file_219
~
param file is:
/home/testDir
Could anyone please help me in finding where the bug is in the script?