get substring from string

Hi All,

Problem Description:

XML_REP_REQUEST=`CONCSUB "$LOGIN" "SQLAP" "$RESP_NAME" "$USRNM" WAIT="Y" "CONCURRENT" "APPLICATION_SHORT_NAME" 
"CP_SHORT_NAME"`
echo Report Request: $XML_REP_REQUEST  --to print value in log file

While execution the value of 'XML_REP_REQUEST' is 'Prozess "4479620" f�r "CONCURRENT TEST_REPORT " gestartet Normal beendet'
I am storing the sub string '4479620' of variable XML_REP_REQUEST in variable 'XML_REP_REQUEST' using code below:

XML_PUB_REQUEST_ID=`echo $XML_PUB_REQUEST |tr -s " "| cut -d" " -f2|tr -d """`

But it's returning "4479620" instead of 4479620.

Any idea where I am going wrong :frowning:

Many thanks,
Suman

---------- Post updated at 02:05 AM ---------- Previous update was at 01:38 AM ----------

topic changed...

"But it's returning "4479620" instead of "4479620"

What is the exact result you expecting?

Suman,

Hope this helps:

echo $XML_PUB_REQUEST |awk -F '"' '{print $2}'

Hi,

I tried with 'echo $XML_PUB_REQUEST |awk -F '"' '{print $2}'' but it's giving error 'awk: can't open {print $2}'.

I got two solutions and it's working fine:

1-XML_PUB_REQUEST_ID=`echo $XML_PUB_REQUEST |tr -s " "|cut -d" " -f2|sed s/\"//g`
2-XML_PUB_REQUEST_ID=`echo $XML_PUB_REQUEST |tr -s " "| cut -d" " -f2|tr -d '"'`

Thanks,
Suman

This work for me in KSH.

Can you create file /tmp/script.ksh
Put text below in this script. Run: chmod +x /tmp/script.ksh ; ./tmp/script.ksh

#!/bin/ksh
XML_PUB_REQUEST='Prozess "4479620" f�r "CONCURRENT TEST_REPORT " gestartet Normal beendet'
echo $XML_PUB_REQUEST |awk -F '"' '{print $2}'

Hi,

I tried as mentioned below but it didn't work with

echo $XML_PUB_REQUEST |awk -F '"' '{print $2}' 

After removing -F '"' from awk command it worked fine.

'echo $XML_PUB_REQUEST |awk '{print $2}'|tr -d '"'`

Many Thanks,
Suman