Bash:How to split one string variable in two variables?

Hello,

I have a paramter $param consisting just of two literals and want to split it into two parameters, so I can combine it to a new parameter <char1><string><char2>, but the following code didn't work:

 
tmp_PARAM_1=cut -c1 $PARAM
tmp_PARAM_2=cut -c2 $PARAM
NewParam=${tmp_PARAM_1}String${tmp_PARAM_2}

Can anyone help me?

THX :slight_smile:

#! /bin/ksh
PARAM=AB
tmp_PARAM_1=`echo $PARAM | cut -c1`
tmp_PARAM_2=`echo $PARAM | cut -c2 `
NewParam=${tmp_PARAM_1}String${tmp_PARAM_2}
echo $NewParam

Like this:

$ cat test.sh
#!/usr/bin/ksh
var="abc = def"
echo $var | IFS="${IFS}=" read KEY VALUE
echo $KEY
echo $VALUE
$ ./test.sh
abc
def