Thanks a lot @vgersh99 and @summer_cherry
I really appreciate the help you people have provided...
---------- Post updated at 05:51 PM ---------- Previous update was at 10:56 AM ----------
Hi,
I implemented the code as below. I'm facing some issue.
Here is my script:
testScript.sh
---------------
#!/bin/sh
arg_1=$1
echo "arg passed by user is:${arg_1}"
mapping=$(awk -F= -v name=${arg_1} '$1 == name {value=$2;exit} END { print (value)?value:"not found"}' testing.conf)
echo "mapping is $mapping"
if [ "${mapping}" = "not found" ]; then
echo "mapping passed as argument is not correct"
help
exit 1
fi
key=param_file_${mapping}
echo "key:${key}:"
param_file=`grep '${key}=' testing.conf | awk -F"=" '{print $2}'`
echo "param file is:${param_file}"
--------------------------------------------------------------------
The config file is as below:
testing.conf:
---------------
ram=219
param_file_219=/home/testDir
-----------------------------------------------------------------------
Now when I run the script as ./testScript.sh ram the output I get is as below:
output
--------------------
arg passed by user is:ram
mapping is 219
:ey
aram_file_219
param file is:
Could anyone kindly let me know what's wrong in the script?