I have a bash script that contains a variable. In the same script, I have an HTML section that, for now, outputs "Hello".
I'd like the HTML section of the bash script to retrieve a variable, and display that in the same heading as the "Hello" section. Essentially, the output on the HTML page should be something like this "Hello Adam".
For now, as simple as it gets, my bash script code is as follows:
#!/bin/bash
firstname="Adam"
echo $firstname
cat << _EOF_
<!DOCTYPE html>
<html>
<body>
<h1>Hello</h1>
</body>
</html>
_EOF_
How do I get the variable in the HTML section so that it can display the $firstname variable?
For reference, I currently run the script using git-bash by executing sh {name-of-script} > test.html
$firstnamein the here doc...<h1>Hello $firstname</h1>sh myscript, you'll run into problems when using Bash specific features such as arrays. You might not even actually run Bash (on Ubuntu,/bin/shis Dash). To avoid that and let the script use the interpreter specified in the shebang line, make it executable and run it with./myscriptinstead.