01-28-07 06:17 PM
2007-01-28, 06:26(-08), Rafael The Engel:
> Hello,
> I need to replace a word in string but the only problem is that the
> word is repeating on itself a couple of times.
> and I need to replace just one show of this word
>
> example:
> insert into TEST
> values('TEXT','Y',NULL,'N',NULL,'5','0',
NULL,NULL,'N',NULL,'N',NULL,NUL
> L,NULL,NULL,NULL,NULL,NULL,SYSDATE,SYSDA
TE,'OP');
>
> I need to change just the first NULL to " '&yuyu' "
[...]
To change the first NULL of each line:
sed "s/NULL/ '\&yuyu' /" < input-file.txt
To only change the second of each line:
sed "s/NULL/ '\&yuyu' /2"
to change the first NULL of the whole file:
sed -e '/NULL/!b' -e "s// '\&yuyu' /" -e :1 -e n -e b1
Or
perl -0777 -pe "s/NULL/ '&yuyu' /"
--
Stéphane
[ Post a follow-up to this message ]
|