Perl one-liner help
March 13, 2012 7:33 PM Subscribe
Perl one-liner help - increment a number in a find-replace situation starting at a specific number?
Here's my one-liner:
perl -p -i -e 's/msdata:rowOrder=\"[0-9]*\"/"msdata:rowOrder=\"$1".(++$i)."\""/ge' file.xml
This finds all the rows in file.xml with the text msdata:rowOrder="18" and replaces the number in quotes incrementally throughout the file with 1, 2, 3, etc.,
How can I modify this so that I can specify the start number (i.e., start at 1000, then 1001, 1002, etc.,)
posted by odinsdream to computers & internet (8 answers total)
posted by introp at 7:39 PM on March 13, 2012 [2 favorites]