Results 1 to 4 of 4
I want to modify all html files in a directory (recursively) in the following way:
1. Find starting body tag (<body>)
2. Just after that insert my custom html tags ...
- 05-11-2007 #1Just Joined!
- Join Date
- Jan 2007
- Posts
- 9
Modifying HTML files in a directory
I want to modify all html files in a directory (recursively) in the following way:
1. Find starting body tag (<body>)
2. Just after that insert my custom html tags (e.g. <p>Hello World</p>)
So my aim is just inserting "<p>Hello World</p>" at the top of the page.
How can i do this? Which command line tools (awk, grep..) should i use? And can you give me some starting point or the command i need to run?
Thanks.
- 05-11-2007 #2
This way should work:
However, this will still insert your tags if they are already there. Check for their existence after <body> in the file if you want to avoid this.Code:for a in `find . -print | grep .*\.html` do sed -i "s/<body>/<body><p>Hello World<\/p>/g" $a done
Regards
- 05-12-2007 #3Just Joined!
- Join Date
- Jan 2007
- Posts
- 9
Thanks for the answer birdman.
- 05-13-2007 #4Linux User
- Join Date
- Aug 2006
- Posts
- 458


Reply With Quote
