Question

Is there a way I can do something like the following using the standard linux toolchain?

Let's say the source at example.com/index.php is:

Hello, & world! "

How can I do something like this...

curl -s http://example.com/index.php | htmlentities

...that would print the following:

Hello, & world! "

Using only the standard linux toolchain?

Was it helpful?

Solution

Use recode.

$ echo 'Hello, & world! "' | recode HTML_4.0
Hello, & world! "

EDIT: By the way, recode offers several different conversions corresponding to different versions of HTML and XML, so you can use e.g. HTML_3.2 instead of HTML_4.0 if you have a really old HTML document. Running recode -l will list all the complete list of charsets supported by the program.

OTHER TIPS

alias decode="php -r 'echo html_entity_decode(fgets( STDIN ));'"

$ echo 'Hello, & world! "' | decode
Hello, & world! "
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top