How to use variables or functions that are defined after the command.
Variable
#!/bin/bash
echo Hello "$who"
who="World"
Function
#!/bin/bash
function_name
function_name() {
echo Hello World
}
I also heard there is a command to read entire bash script before executing any commands, this would work for my case. But it would be nice if there is a more pinpoint way.
More in-depth
#!/bin/bash
h=Hello
echo $h "$who"
var1=World
who=$(cat <<HEREDOC
You
Me
$var1
HEREDOC
)