0

I have a shell script, where I have included a file which contains variables with some assigned values.

When I execute the shell script to concatenate the variables from the included file, it is behaving weird.

Here when the variables are echoed separated, they provide expected value. But when I concatenate the two variables, the second variable is overwriting the first one.

Config File - conf.cfg

var1=xxxxxxxx
var2=yyyyyy

Show Script - Show.sh

source ./conf.cnf

echo $var1
echo $var2
echo $var1$var2

Expected Result

xxxxxxxx
yyyyyy
xxxxxxxxyyyyyy

Actual Result

xxxxxxxx
yyyyyy
yyyyyyxx
melpomene
  • 84,125
  • 8
  • 85
  • 148
  • `conf.cfg` is in DOS format (carriage returns at the end of each line). There's probably a duplicate question around somewhere. – melpomene Jul 03 '19 at 18:58
  • Thanks a lot for your response. My file is using .cnf or .cfg which were in DOS not being included properly in the the shell script. So I changed it to .txt and included in the shell script. It was working fine. – sriramprasad7 Jul 03 '19 at 19:06
  • That seems unlikely. – melpomene Jul 03 '19 at 19:07

1 Answers1

0

It just got resolved after I changed the extension of the conf file from .cfg to .txt