![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep for a pattern based on another patter | rock1 | UNIX for Dummies Questions & Answers | 7 | 10-18-2008 05:32 PM |
| Truncating FILE data BASED ON A PATTERN | pkumar3 | Shell Programming and Scripting | 1 | 10-14-2008 11:49 AM |
| how to change a particular value in a file based on a pattern | orbeyen | UNIX for Dummies Questions & Answers | 9 | 08-20-2008 03:09 AM |
| appending with sed based on matched pattern | jack1981 | Shell Programming and Scripting | 2 | 07-20-2006 06:54 AM |
| appending string to text file based on search string | malaymaru | Shell Programming and Scripting | 1 | 06-09-2006 08:53 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
String spllittinf based on pattern
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 |
|
||||
|
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 |
|
||||
|
Code:
#!/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)" |
![]() |
| Bookmarks |
| Tags |
| shell script, shell scripting, unix scripting, unix scripting basics |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|