Re: Search and Replace with Different Text
- From: Deepan MYSQL <deepan.17@xxxxxxxxx>
- Date: Mon, 8 Jun 2009 06:19:29 -0700 (PDT)
On Jun 8, 6:08 pm, pk <p...@xxxxxxxxxx> wrote:
On Monday 8 June 2009 15:03, pk wrote:
awk -v len=5 'NR==FNR {repl[FNR]=$0;next}
/<imsi>/{
$0="<imsi>"sprintf("%0"len"d", repl[++count]) substr($0,12)
}
{print}
' myDataFile CDUSARBFIN2G99277.xml > new.xml
There's an error in that code, sorry.
awk -v len=5 'NR==FNR {repl[FNR]=$0;next}
/<imsi>/{
sub(/^[[:space:]]*/,"")
$0="<imsi>"sprintf("%0"len"d", repl[++count]) substr($0,12)
$0="\t\t\t<imsi>" # or whatever leading blank you need}
{print}
' myDataFile CDUSARBFIN2G99277.xml > new.xml
This replaces the <imsi>244121000003812</imsi> to just <imsi>.. I want
to replace only the first five digits.. say from
<imsi>244121000003812</imsi> to <imsi>272011000003812</imsi> 27201
being the first or second or any element from the array..
.
- Follow-Ups:
- References:
- Search and Replace with Different Text
- From: Deepan MYSQL
- Re: Search and Replace with Different Text
- From: pk
- Re: Search and Replace with Different Text
- From: Deepan MYSQL
- Re: Search and Replace with Different Text
- From: pk
- Re: Search and Replace with Different Text
- From: Deepan MYSQL
- Re: Search and Replace with Different Text
- From: Marcel Bruinsma
- Re: Search and Replace with Different Text
- From: Deepan MYSQL
- Re: Search and Replace with Different Text
- From: pk
- Re: Search and Replace with Different Text
- From: pk
- Search and Replace with Different Text
- Prev by Date: Re: Search and Replace with Different Text
- Next by Date: Re: Search and Replace with Different Text
- Previous by thread: Re: Search and Replace with Different Text
- Next by thread: Re: Search and Replace with Different Text
- Index(es):