I have a script that I am using for a large scale find and replace. When a match is found in a particular file, I record the file name, and the line number.
What I want to do is for each file name, line number pair, change a string from <foo>
to <bar>
on only that line of the file.
In my shell script, I am executing a find and replace command on the file given the line number...
run=`perl -pi -e "s/$find/$replace/ if $. = $lineNum" $file`
This however I believe has been ignoring the $. = $lineNum
and just does the s/$find/$replace/
on the whole file, which is really bad.
Any ideas how I can do this?