L
Lars Eighner
Can I capture a group of digits, perform integer arithmetic on them,
and use them in the replacement?
Say I have a group of files named Fife_Ch01.html, Fife_Ch02.html
and so forth. The files all have a line with their own name. I want
to replace the file name with the next number and do not care about
leading zeros.
So,
Fife_Ch01.html is replaced with 2
Fife_Ch02.html is replaced with 3
and so forth.
Can I do this with a one-liner?
it would look something like this:
#perl -pi -e 's/Fife_Ch([0-9]*)\.html{a miracle happens}/\1/' Fife_Ch*.html
and use them in the replacement?
Say I have a group of files named Fife_Ch01.html, Fife_Ch02.html
and so forth. The files all have a line with their own name. I want
to replace the file name with the next number and do not care about
leading zeros.
So,
Fife_Ch01.html is replaced with 2
Fife_Ch02.html is replaced with 3
and so forth.
Can I do this with a one-liner?
it would look something like this:
#perl -pi -e 's/Fife_Ch([0-9]*)\.html{a miracle happens}/\1/' Fife_Ch*.html