appending two strings

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
~ey:param_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:param_file_219~
param file is:/home/testDir

Could anyone please help me in finding where the bug is in the script?

Your code works for me in both ksh and bash. Check for a hidden character in testing.conf.

Yep. Works fine for me too.

Here goes the data in testing.conf

[home@27]$ sed -n l testing.conf
ram=219\r$
param_file_219=/home/testDir\r$
ram_kumar=220\r$
param_file_220=/home/testdir1\r$

any suggestions???

Yes -

$ perl -pi -e 's/\r//g' testing.conf

tyler_durden