I've a file over 2k lines which looks like:
pl (IdPl,X,Y,TitleLine,Name,Description,idRowMetric,idPlMetric,Person) Values (26916,1000,3750,'','','11',null,NULL,1)
pla (IdPl,EncLevel,IdSection) Values (26916,2,21)
pla(IdPl,EncLevel,IdSection) Values (26916,1,1065)
Pl (IdPl,X,Y,TitleLine,Name,Description,idRowMetric,idPlMetric,Person) Values (26917,2900,3750,'','','11',null,NULL,1)
Pla(IdPl,EncLevel,IdSection) Values (26917,2,21)
Pla (IdPl,EncLevel,IdSection) Values (26917,1,1065)
Pl (IdPl,X,Y,TitleLine,Name,Description,idRowMetric,idPlMetric,Person) Values (26918,1050,3750,'','','11',null,NULL,1)
Pla (IdPl,EncLevel,IdSection) Values (26918,2,21)
Pla (IdPl,EncLevel,IdSection) Values (26918,1,1065)
Pl (IdPl,X,Y,TitleLine,Name,Description,idRowMetric,idPlMetric,Person) Values (26919,1100,3750,'','','11',null,NULL,1)
Pla (IdPl,EncLevel,IdSection) Values (26919,2,21)
Pla (IdPl,EncLevel,IdSection) Values (26919,1,1065)
How do I replace all 26916 on -1, 26917 on -2 and etc using sed or awk?
Using sed:
sed -r 's/(.*)([0-9]{5})(.*)/echo "\1$((-(\2-26915)))\3"/ge' file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With