D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Mass editing text files?

 

> The above can be made much simpler by use of the -pi flags which
> allow for in-place editing of files with a backup copy made.  e.g.:
>
> perl -npi.bak -e 's#<head>#<head>\nYour extra stuff here#i;' *.html
>
This looks like the simplest approach - especially for a person like
me who doesn't know much programming!

I have a question though: if I wanted the text to be inside the <head>
section would it read:

perl -npi.bak -e 's#<head>\nExtra stuff here#i;\n' *.html

?

The result I'm looking for is:

<head>

Extra stuff

stuff that was there before

</head>

Thanks for your help everyone!

Jon

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html