Hi,
I have a sample.properties file and it contains the following content.
today--RSS_URL=http://someurl
i need to split the string and need the result in the folliwng form.
x1=today
x2=RSS_URL
x3=http://someurl
Your immediate response will be graetly appreciated
Konerak
2
echo "today--RSS_URL=http://someurl" | sed 's/\(.*\)--\(.*\)=\(.*\)/x1=\1\nx2=\2\nx3=\3/'
x1=today
x2=RSS_URL
x3=http://someurl
Thanks Koneark,
but i have one more prob here.
when i run
echo "today--RSS_URL=http://someurl" | sed 's/\(.*\)--\(.*\)=\(.*\)/x1=\1\nx2=\2\nx3=\3/'
it is giving the out as below.
x1=todaynx2=RSS_URLnx3=http://someurl
But I need the out put as
x1=today
x2=RSS_URL
x3=http://someurl
and i need to export these x1, x2 and x3 to the shell.
Thanks,
Eswar
Konerak
4
#!/bin/sh
var='today--RSS_URL=http://someurl'
x1=`echo $var | sed "s_\(.*\)--\(.*\)=\(.*\)_\1_"`
x2=`echo $var | sed "s_\(.*\)--\(.*\)=\(.*\)_\2_"`
x3=`echo $var | sed "s_\(.*\)--\(.*\)=\(.*\)_\3_"`
echo "Testing results: var($var) x1($x1) x2($x2) x3($x3)"
This script will set the variables as you wish. You can export them or modify them or do whatever you want with them then.