![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to supplement HTML tags with SED | DocBrewer | Shell Programming and Scripting | 3 | 04-25-2008 09:40 AM |
| html tags | dunryc | Shell Programming and Scripting | 3 | 11-29-2007 06:14 PM |
| How to remove only html tags inside a file? | btech_raju | Linux | 2 | 11-23-2007 12:25 PM |
| Automated replacement of HTML Tags | nem_kirk | SUN Solaris | 1 | 11-17-2005 01:24 AM |
| unsing sed to strip html tags - help | zap | Shell Programming and Scripting | 3 | 04-18-2004 04:03 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
||||
|
Remove html tags with bash
Hello,
is there a way to go through a file and remove certain html tags with bash? If it needs sed or awk, that'll do too. The reason why I want this is, because I have a monitor script which generates a logfile in HTML and every time it generates a logfile, the tags are reproduced. The tags I want removed are </body> and </html> and are the last two lines in the HTML file. I found similar topics, but none of them do what I need. delete to end of line with SED Thanks in advance for the help. |
|
||||
|
It kinda works, but somehow I have to forward the output to a new file.
Code:
awk '/<\/body>/ || /<\/html>/{next}1' file.html > file2.html
When I use: Code:
awk '/<\/body>/ || /<\/html>/{next}1' file.html > file.html
All the code before the </body> and </html> tags should remain in the file. Thanks |
|
||||
|
You can't redirect the output to the inputfile. Redirect the output to a temporary file and move it to the original file, something like this:
Code:
awk '/<\/body>/ || /<\/html>/{next}1' file.html > file1.html
mv file1.html file.html
|
|
||||
|
Just figured it out some minutes ago, same way like you wrote the code, before you replied. Thanks for all the help
![]() |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|