![]() |
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 Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help me with parsing this file | eamani_sun | Shell Programming and Scripting | 2 | 05-16-2008 03:39 PM |
| awk and file parsing | devtakh | Shell Programming and Scripting | 4 | 05-06-2008 11:13 AM |
| Parsing a csv file | chiru_h | Shell Programming and Scripting | 6 | 02-12-2008 09:33 AM |
| File Parsing | jsusheel | Shell Programming and Scripting | 5 | 09-25-2007 10:25 AM |
| parsing file through awk | bbeugie | Shell Programming and Scripting | 13 | 08-22-2006 01:21 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi All,
I have this(.xml) file as: Code:
<!-- define your instance here -->
<instance name='ins_C2Londondev' user='' group='' fullname='B2%20-%20London%20(dev)' >
<property>
</property>
</instance>
Code:
<!-- define your instance here -->
<instance name='ins_B2Londondev' user='C2_dev' group='sports' fullname='B2%20-%20London%20(dev)' >
<property>
</property>
</instance>
Thanks in advance Last edited by Yogesh Sawant; 04-08-2008 at 04:39 AM.. Reason: added code tags |
|
||||
|
Perhaps you could elaborate on your requirements. If all you need is to change name='ins_C2Londondev' to name='ins_B2Londondev', change user='' to user='C2_dev', change group='' to group='sports' regardless of context, then you don't really need any XML parsing. Oh, and if the new values somehow depend on the input, we can't guess what they need to be, so you need to explain that. On the other hand, if you need real XML parsing, sed is not the right tool.
Code:
sed -e "s/name='ins_C2Londondev'/name='ins_B2Londondev'/" \
-e "s/user=''/user='C2_dev'/" -e "s/group=''/group='sports'/" file.xml
|
|
||||
|
First of all thx for your time.This is the complete .xml file:<name>B2 - London</name>
<description>Calculates risk numbers for the global SCT desk and london credit flow desk</description> <version>1.0</version> <revision></revision> <revcomment></revcomment> <bline>Fixed Income</bline> <userid>kkinha</userid> <!-- define your global properties here --> <property> <SRC_PATH>/home/B2_dev/grid/B2_RiskEngine_Grid/OvernightLondon/VB2.STABLE</SRC_PATH> </property> <!-- define your instance here --> <instance name='ins_B2Londondev' user='' group='' fullname='B2%20-%20London%20(dev)' > <!-- ins_B2Londondev = B2 - London (dev) --> <!-- define your instance specific properties here --> <property> </property> </instance> <instance name='ins_B2Londonprod' user='' group='' fullname='B2%20-%20London%20(prod)' > <!-- ins_B2Londonprod = B2 - London (prod) --> <!-- define your instance specific properties here --> <property> </property> </instance> <instance name='ins_B2LondonInt' user='' group='' fullname='B2%20-%20London%20(Stage)' > <!-- ins_B2LondonInt = B2 - London (Stage) --> <!-- define your instance specific properties here --> <property> </property> </instance> <component name='Undefined'> <version>1.0</version> <os>Red Hat Enterprise Linux AS 4</os> <os>SunOS 5.8</os> <package>B2_GridComponentInstall</package> </component> <package name='B2_GridComponentInstall'> <description>Package for deploying B2 - London</description> <version>1.0</version> <dir src='${SRC_PATH}' dst='/home/${user}' owner='${user}' group='${group}' type='' exclude='' perm='755' option='' /> <post>${SRC_PATH}/deployOvernightRiskEngine.bat</post> <auto_home key='${user}' path='/local/0/home/${user}' server='localhost' /> </package> </application> I have to change user='' to user='C2_Dev' , group='' to group='sports' and dst='/home/${user} to dst=$DST_PATH.Where DST_PATH is shell script variable.User and group shd be changed depending on user input i.e instance name for ex. if instance name is ins_B2Londondev then user and group for that instance shd be changed.I am doin like this buts it's giving error: sed -n \ "/${Instance}/p"\ -e '/instance name/p'\ -e "s/user=''/user='B2_dev'/" -e "s/group=''/group='games'/" B2GridTemplate.xml Error::Can't open -e Can't open /instance name/p Can't open -e Can't open s/user=''/user='B2_dev'/ Can't open -e Can't open s/group=''/group='games'/ <instance name='ins_B2Londondev' user='' group='' fullname='B2%20-%20London%20(dev)' > <!-- ins_B2Londondev = B2 - London (dev) --> Please help!!!! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|