I am on Redhat and I am new to shell programming.I am trying create directory by combining three names.I have a property file, this is what it looks like:build_name = MyBuildbuild_no   = 100appServer_version = jboss6.1`I read this property file and I am trying to create a directory by combining all three names. After creating directory it should look like that.MYBuild-100-jboss6.1Here what I have tried file=./app.propertiesif [ -f $file ]then  echo $file found.  while IFS='=' read -r key value  do    key=$(echo $key | tr '.' '_')    eval ${key}='${value}'  done < $file    echo build_name    =  ${build_name}    echo build_no      =  ${build_no}    echo Jboss_version     = ${jboss_version}    echo Got the value from property file name=${build_name}- build=${build_no}- Jboss=${jboss_version} fileName=${name}${build}${Jboss}    mkdir $fileNameelse  echo $file not found.fiWhen I run this , It always create three different directory,with name MyBuild , 100 , jboss6.1. Where am doing wrong.can any one help me? update 1file=./app.propertiesARRAY=()if [ -f $file ]then  echo $file found.  IFS='='  while read -r key value  do    val=$(echo $value | tr -d '[[:space:]]')    ARRAY+=($val)  done < $file  IFS='-'  newdir=${ARRAY[*]}  echo mkdir $newdir    if[ -f $newdir ]    then     echo $newdir allready exist.    rm -rf $newdir    mkdir $newdir    else    mkdir $newdirelse  echo $file not found.fi
How to create a directory by combining two name?
shell script
You have two issue there, first are spaces which are left in your variables when you perform the read with IFS='='.  Second is that you actually do not have jboss_version in your app file.  One way to do this would be:file=./app.propertiesif [ -f $file ]then  echo $file found.  while IFS='=' read -r key value  do    key=$(echo $key | tr '.' '_' | tr -d ' ' | tr -d '\t')    val=$(echo $value | tr -d ' ' | tr -d '\t')    eval ${key}='${val}'  done < $file    echo build_name    =  ${build_name}    echo build_no      =  ${build_no}    echo Jboss_version     = ${appServer_version}    echo Got the value from property file name=${build_name}- build=${build_no}- Jboss=${appServer_version} fileName=${name}${build}${Jboss}    echo mkdir [$fileName]else  echo $file not found.fiYet, I would do it in a different way.  By forcing IFS to be used in the split and in the join as well, this also uses all variables from the app.properties file:file=./app.propertiesARRAY=()if [ -f $file ]then  echo $file found.  IFS='='  while read -r key value  do    val=$(echo $value | tr -d '[[:space:]]')    ARRAY+=($val)  done < $file  IFS='-'  newdir=${ARRAY[*]}  if [ -d $newdir ]; then      echo rm -rf $newdir      rm -rf $newdir  fi  echo mkdir $newdir  mkdir $newdirelse  echo $file not found.fi