in reply to to copy certain content in file & repeat it .
perl -pi.bak -07d -e 's/(hero\{.*)/$1 . 'copy_' . $1/es;' filename.txt
Untested. It should set the input record separator to the '}' character, and then finding the start tag it subs everything between start and end tags with a second copy, and makes a backup just in case I got it entirely wrong. ;)
The /e isn't strictly necessary, but it allowed me to make the right hand side of the s/// operator easier to read.
Dave
|
|---|