Skip to content Skip to sidebar Skip to footer

Linux Bash And Html Variables (import And Export)

I've something like: var1=name var2=surname I need export these variables and import it to html file any idea?

Solution 1:

echo "<html><body>" > index.html
echo "var1 is $var1 <br>" >> index.html
echo "var2 is $var2 <br>" >> index.html
echo "</body></html>" >> index.html

Solution 2:

For a simplistic form of templating, you can do

var1=name
var2=surname

cat > somefile.html << EOF
  <title>$var1's demo page!</title>
  <body>
    Hello, $var1 $var2. 
  </body>
EOF

Post a Comment for "Linux Bash And Html Variables (import And Export)"