sed: replace only the first range of numbers
- by Marit Hoen
Imagine I have an input file like this:
INSERT INTO video_item_theme VALUES('9', '29');
INSERT INTO video_item_theme VALUES('19', '312');
INSERT INTO video_item_theme VALUES('414', '1');
And I wish to add 10000 to only the first range of numbers, so I end up with something like this:
INSERT INTO video_item_theme VALUES('10009', '29');
INSERT INTO video_item_theme VALUES('10019', '312');
INSERT INTO video_item_theme VALUES('10414', '1');
My approach would be to prefix "1000" to one digit numbers, "100" Something like...:
sed 's/[0-9]\{2\}/10&/g'
... isn't very helpful, since it changes each occurance of two numbers, not only in the first occurance of numbers:
INSERT INTO video_item_theme VALUES('9', '10029');
INSERT INTO video_item_theme VALUES('10019', '100312');
INSERT INTO video_item_theme VALUES('100414', '1');