Results 1 to 5 of 5
Hi,
I am having a file as follows
<VR NM="SID" VL="2004"/>
<VR NM="EID" VL="604"/>
<VR NM="SID" VL="2005"/>
<VR NM="EID" VL="605"/>
<VR NM="SID" VL="2006"/>
<VR NM="EID" VL="606"/>
<VR NM="SID" VL="2007"/>
<VR ...
- 10-21-2008 #1Just Joined!
- Join Date
- Oct 2006
- Location
- Banagalore
- Posts
- 13
script to replace a text
Hi,
I am having a file as follows
Now i want to change 601 with 501 602 with 502 and so on.<VR NM="SID" VL="2004"/>
<VR NM="EID" VL="604"/>
<VR NM="SID" VL="2005"/>
<VR NM="EID" VL="605"/>
<VR NM="SID" VL="2006"/>
<VR NM="EID" VL="606"/>
<VR NM="SID" VL="2007"/>
<VR NM="EID" VL="607"/>
<VR NM="SID" VL="2008"/>
<VR NM="EID" VL="608"/>
<VR NM="SID" VL="2009"/>
<VR NM="EID" VL="609"/>
please help me out which command should i use to solve this.
thanks in advance
Now i want to change value with
- 10-22-2008 #2Just Joined!
- Join Date
- Apr 2007
- Posts
- 59
Hi Rajesh,
See if this works for you.
Sandeep ThakkarCode:var="601" var2="501" cp file1 file2 while [ 1 ] do if grep $var file1 then sleep 1 sed 's/'$var'/'$var2'/' file2 > file3 mv file3 file2 var=`expr $var + 1` var2=`expr $var2 + 1` else exit 0; fi done
Pune
- 10-22-2008 #3Just Joined!
- Join Date
- Oct 2006
- Location
- Banagalore
- Posts
- 13
thanks for reply.
My values will varies each time.
those 601 and 602 are not fixed.
thanks in advance
- 10-22-2008 #4Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
Possibly, you want something like this:
Code:awk '/EID/ {match($0, /[0-9]+/); num = substr($0, RSTART, RLENGTH); sub(num, num - 100); print;}'
- 10-22-2008 #5Just Joined!
- Join Date
- Oct 2006
- Location
- Banagalore
- Posts
- 13
scritp to replace a text
thanks.
But i have different problem
I am putting my file.
Now i want to change the number in the following lineCode:<?xml version="1.0" encoding="iso-8859-1"?> <!-- edited with XML Spy v3.5 NT (http://www.xmlspy.com) by Umashankar (NDS) --> <DF NM="REN_EPG_WELCOME_TABLE"> <DB NM="EVENTS_DB"> <VT NM="WELCOME_DAY"> <IT NM="WELCOME_DAY_1"> <VR NM="WELCOME_DATE" VL="22/10/08"/> <VT NM="PROG_EVENT"> <IT NM="COMBO1_3 - Event 121"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="1724"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:tfuret.png"/> </IT> <IT NM="COMBO1_3 - Event 122"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="1725"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:pruggier.png"/> </IT> <IT NM="COMBO1_3 - Event 123"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="1726"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:fbellang.png"/> </IT> <IT NM="COMBO1_3 - Event 124"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="1727"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:ctrouillet.png"/> </IT> </VT> <VT NM="VOD_EVENT"> <IT NM="VOD_EVENT_2"> <VR NM="CONTENT_ID" VL="12346"/> <VR NM="ORIGINAL_NETWORK_ID" VL="192"/> <VR NM="TRANSPORT_STREAM_ID" VL="1540"/> <VR NM="SERVICE_ID" VL="2004"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> <VR NM="BASELINE" VL="AAAAAAAA"/> <VR NM="CATALOG_NAME" VL="BBBBBBBBBB"/> <VR NM="CONTENT_NAME" VL="CCCCCCCC"/> </IT> </VT> </IT> <IT NM="WELCOME_DAY_2"> <VR NM="WELCOME_DATE" VL="23/10/08"/> <VT NM="PROG_EVENT"> <IT NM="COMBO1_3 - Event 121"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="1864"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:agaltier.png"/> </IT> <IT NM="COMBO1_3 - Event 122"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="1865"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> </IT> <IT NM="COMBO1_3 - Event 123"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="1866"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:ctrouillet.png"/> </IT> <IT NM="COMBO1_3 - Event 124"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="1867"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:tfuret.png"/> </IT> </VT> <VT NM="VOD_EVENT"> <IT NM="VOD_EVENT_3"> <VR NM="CONTENT_ID" VL="12347"/> <VR NM="ORIGINAL_NETWORK_ID" VL="192"/> <VR NM="TRANSPORT_STREAM_ID" VL="1540"/> <VR NM="SERVICE_ID" VL="2004"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> <VR NM="BASELINE" VL="AAAAAAAA"/> <VR NM="CATALOG_NAME" VL="BBBBBBBBBB"/> <VR NM="CONTENT_NAME" VL="CCCCCCCC"/> </IT> </VT> </IT> <IT NM="WELCOME_DAY_3"> <VR NM="WELCOME_DATE" VL="24/10/08"/> <VT NM="PROG_EVENT"> <IT NM="COMBO1_3 - Event 121"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2004"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:agaltier.png"/> </IT> <IT NM="COMBO1_3 - Event 122"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2005"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> </IT> <IT NM="COMBO1_3 - Event 123"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2006"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:ctrouillet.png"/> </IT> <IT NM="COMBO1_3 - Event 124"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2007"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:tfuret.png"/> </IT> </VT> <VT NM="VOD_EVENT"> <IT NM="VOD_EVENT_3"> <VR NM="CONTENT_ID" VL="12347"/> <VR NM="ORIGINAL_NETWORK_ID" VL="192"/> <VR NM="TRANSPORT_STREAM_ID" VL="1540"/> <VR NM="SERVICE_ID" VL="2004"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> <VR NM="BASELINE" VL="AAAAAAAA"/> <VR NM="CATALOG_NAME" VL="BBBBBBBBBB"/> <VR NM="CONTENT_NAME" VL="CCCCCCCC"/> </IT> </VT> </IT> <IT NM="WELCOME_DAY_4"> <VR NM="WELCOME_DATE" VL="25/10/08"/> <VT NM="PROG_EVENT"> <IT NM="COMBO1_3 - Event 121"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2144"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:agaltier.png"/> </IT> <IT NM="COMBO1_3 - Event 122"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2145"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> </IT> <IT NM="COMBO1_3 - Event 123"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2146"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:ctrouillet.png"/> </IT> <IT NM="COMBO1_3 - Event 124"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2147"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:tfuret.png"/> </IT> </VT> <VT NM="VOD_EVENT"> <IT NM="VOD_EVENT_3"> <VR NM="CONTENT_ID" VL="12347"/> <VR NM="ORIGINAL_NETWORK_ID" VL="192"/> <VR NM="TRANSPORT_STREAM_ID" VL="1540"/> <VR NM="SERVICE_ID" VL="2004"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> <VR NM="BASELINE" VL="AAAAAAAA"/> <VR NM="CATALOG_NAME" VL="BBBBBBBBBB"/> <VR NM="CONTENT_NAME" VL="CCCCCCCC"/> </IT> </VT> </IT> <IT NM="WELCOME_DAY_5"> <VR NM="WELCOME_DATE" VL="26/10/08"/> <VT NM="PROG_EVENT"> <IT NM="COMBO1_3 - Event 121"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2284"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:agaltier.png"/> </IT> <IT NM="COMBO1_3 - Event 122"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2285"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> </IT> <IT NM="COMBO1_3 - Event 123"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2286"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:ctrouillet.png"/> </IT> <IT NM="COMBO1_3 - Event 124"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2287"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:tfuret.png"/> </IT> </VT> <VT NM="VOD_EVENT"> <IT NM="VOD_EVENT_3"> <VR NM="CONTENT_ID" VL="12347"/> <VR NM="ORIGINAL_NETWORK_ID" VL="192"/> <VR NM="TRANSPORT_STREAM_ID" VL="1540"/> <VR NM="SERVICE_ID" VL="2004"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> <VR NM="BASELINE" VL="AAAAAAAA"/> <VR NM="CATALOG_NAME" VL="BBBBBBBBBB"/> <VR NM="CONTENT_NAME" VL="CCCCCCCC"/> </IT> </VT> </IT> <IT NM="WELCOME_DAY_6"> <VR NM="WELCOME_DATE" VL="27/10/08"/> <VT NM="PROG_EVENT"> <IT NM="COMBO1_3 - Event 121"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2424"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:agaltier.png"/> </IT> <IT NM="COMBO1_3 - Event 122"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2425"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> </IT> <IT NM="COMBO1_3 - Event 123"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2426"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:ctrouillet.png"/> </IT> <IT NM="COMBO1_3 - Event 124"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2427"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:tfuret.png"/> </IT> </VT> <VT NM="VOD_EVENT"> <IT NM="VOD_EVENT_3"> <VR NM="CONTENT_ID" VL="12347"/> <VR NM="ORIGINAL_NETWORK_ID" VL="192"/> <VR NM="TRANSPORT_STREAM_ID" VL="1540"/> <VR NM="SERVICE_ID" VL="2004"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> <VR NM="BASELINE" VL="AAAAAAAA"/> <VR NM="CATALOG_NAME" VL="BBBBBBBBBB"/> <VR NM="CONTENT_NAME" VL="CCCCCCCC"/> </IT> </VT> </IT> <IT NM="WELCOME_DAY_7"> <VR NM="WELCOME_DATE" VL="28/10/08"/> <VT NM="PROG_EVENT"> <IT NM="COMBO1_3 - Event 121"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2564"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:agaltier.png"/> </IT> <IT NM="COMBO1_3 - Event 122"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2565"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> </IT> <IT NM="COMBO1_3 - Event 123"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2566"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:ctrouillet.png"/> </IT> <IT NM="COMBO1_3 - Event 124"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2567"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:fbellang.png"/> </IT> </VT> <VT NM="VOD_EVENT"> <IT NM="VOD_EVENT_1"> <VR NM="CONTENT_ID" VL="12345"/> <VR NM="ORIGINAL_NETWORK_ID" VL="192"/> <VR NM="TRANSPORT_STREAM_ID" VL="1540"/> <VR NM="SERVICE_ID" VL="2004"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> <VR NM="BASELINE" VL="AAAAAAAA"/> <VR NM="CATALOG_NAME" VL="BBBBBBBBBB"/> <VR NM="CONTENT_NAME" VL="CCCCCCCC"/> </IT> </VT> </IT> <IT NM="WELCOME_DAY_8"> <VR NM="WELCOME_DATE" VL="29/10/08"/> <VT NM="PROG_EVENT"> <IT NM="COMBO1_3 - Event 121"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2704"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:agaltier.png"/> </IT> <IT NM="COMBO1_3 - Event 122"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2705"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> </IT> <IT NM="COMBO1_3 - Event 123"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2706"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:ctrouillet.png"/> </IT> <IT NM="COMBO1_3 - Event 124"> <VR NM="ONID" VL="192"/> <VR NM="TSID" VL="1540"/> <VR NM="SID" VL="2004"/> <VR NM="EID" VL="2707"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:fbellang.png"/> </IT> </VT> <VT NM="VOD_EVENT"> <IT NM="VOD_EVENT_1"> <VR NM="CONTENT_ID" VL="12345"/> <VR NM="ORIGINAL_NETWORK_ID" VL="192"/> <VR NM="TRANSPORT_STREAM_ID" VL="1540"/> <VR NM="SERVICE_ID" VL="2004"/> <VR NM="PICTURE" VL="dtv-d://epg_ren.events_images:calix.png"/> <VR NM="BASELINE" VL="AAAAAAAA"/> <VR NM="CATALOG_NAME" VL="BBBBBBBBBB"/> <VR NM="CONTENT_NAME" VL="CCCCCCCC"/> </IT> </VT> </IT> </VT> </DB> </DF>
<VR NM="EID" VL="2706"/> (sample but so many with different numbers in red color)
i want to change the numbers (not fixed) in red color with other different numbers (not fixed) at all occurrences in the file.


Reply With Quote