I want to generate a static website from a shell script.
A example for the shell script code is:
author="Github INC."
name="Github"
description="social coding"
text=$(awk '{ print }' main.html)
The main.html could look like this:
<!DOCTYPE html>
<html>
<head>
<title>$name</title>
</head>
<body>
......
I want to replace the $name string in the html document between the title tag with the $name string in the bash script (in this example Github) so in this example it should look like this:
<!DOCTYPE html>
<html>
<head>
<title>Github</title>
</head>
<body>
......
I could do this by changing the shell script Code to this:
author="Github INC."
name="Github"
description="social coding"
text="$( sed "s/<title>.*<\/title>/<title>$name<\/title>" main.html )"
But if I use more then one string in the html document, then it won't work anymore...
For example:
<!DOCTYPE html>
<html>
<head>
<title>$name</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="robots" content="index, follow" />
<meta name="author" content="$author" />
<meta name="description" content="$description" />
<link rel="shortcut icon" href="favicon.png" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
Any ideas how to connect the strings from the Shell Script with the HTML Document?
sed 's/1/2/g;s/a/b/g;s/txt/newTxt/g'allows you to change as many lines as you want. Typically for more than a couple of sed cmds (more than my example above), people put all of the sed actions into a seperate file, 1 cmd per line, and then execute likesed -f mySedFixer.sed myTest.html.template > myTest.htmlOr if your workin in Linux, see if you sed supports the-ioption, which saves modifications to the named file(s) without need to redirect into a temporary file, and rename. Good luck.sedprocesses input line by line.