'Can it call a function from outside in eof?
I tried $(hello) ${hello} in this way, but I did not get any successful results.
hello(){
print "Hey I m Here"
}
# test
cat -e <<EOF
# hello ?
hello
EOF
Solution 1:[1]
Assuming this is bash, command substitution should work: $(hello)
"print", however, will not work. Change it to "printf" or "echo".
bash-3.2$ cat doit.sh
hello(){
printf "Hey I m Here"
}
# test
cat -e <<EOF
# hello ?
$(hello)
EOF
bash-3.2$ . ./doit.sh
# hello ?$
Hey I m Here$
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
