Showing posts with label sed. Show all posts
Showing posts with label sed. Show all posts

Wednesday, May 11, 2011

Monday, December 24, 2007

SED: The simplest example

>echo I am older | sed -e 's/old/new/g'
I am newer

SED: Converting carat symbols to HTML special characters

Goal: Show HTML and PHP code, rather than have it interpreted by the web browser.

Using a GNU or Unix command line, myWebpage.html is a regular fully working HTML web page, here is the command:

sed -e 's/\</\&#60;/g' -e 's/\>/\&#62;/g' myWebpage.html > newWebpage.html

Bash Program To Convert Tags to Special Characters
#!/usr/bin/env bash
echo  "lancemiller777@gmail.com"
echo "Argument 1 is file with html tags"
echo "sed -e 's/\</\&#60;/g' -e 's/\>/\&#62;/g' \${1}"
sed -e 's/\</\&#60;/g' -e 's/\>/\&#62;/g' ${1}