Concatenating variables

Hi all,

I'm trying to do a very simple script, as you can see as follow:

#!/bin/bash

#Valorizzazione Token presenti nel file di properties
        var_path_weblogic="`cat weblogic.properties | grep "dir_wl" | /usr/xpg4/bin/awk '{print $3}'`"
        var_ip_address="`cat weblogic.properties | grep -i "ip_address" | /usr/xpg4/bin/awk '{print $3}'`"
        var_port="`cat weblogic.properties | grep -i port | /usr/xpg4/bin/awk '{print $3}'`"
        var_username="`cat weblogic.properties | grep -i username | /usr/xpg4/bin/awk '{print $3}'`"
        var_password="`cat weblogic.properties | grep -i password | /usr/xpg4/bin/awk '{print $3}'`"
        var_name="`cat weblogic.properties | grep -i "name" |grep -v username| /usr/xpg4/bin/awk '{print $3}'`"
        var_war_path="`cat weblogic.properties | grep -i "war_path" | /usr/xpg4/bin/awk '{print $3}'`"

result = "`echo $var_path_weblogic`"

echo $result

....but when I execute the script, result variable is empty (I'm using only a variable to see if the script works).
I'd like to concatenate all variables, but first I'd want to understand because result is empty.

result = "`echo $var_path_weblogic`"

check the white space and remove it

I'm sorry but I don't find any white space, where's it? :frowning:

Remove the spaces around the = sign:

result="`echo $var_path_weblogic`"

instead of:

result = "`echo $var_path_weblogic`"

BTW are you going for the Useless Use of Cat Award?

Ok, right. In the meantime you're writing, I found the problem.

Thanks.

Or useless use of echo

result="$var_path_weblogic"

---------- Post updated at 20:48 ---------- Previous update was at 20:13 ----------

Perhaps you could try something like this:

while read val1 val2 val3 val4; do
  line="$val1 $val2 $val3 $val4"
  case $line in
     *dir_wl*)     var_path_weblogic=$val3 ;;
     *ip_address*) var_ip_address=$val3    ;;
     *port*)       var_port=$val3          ;;
     *username*)   var_username=$val3      ;;
     *password*)   var_password=$val3      ;;
     *name*)       var_name=$val3          ;;
     *war_path*)   var_war_path=$val3      ;;
  esac
done < weblogic.properties

result="$var_path_weblogic"
echo $result