Home > front end >  Can it call a function from outside in eof?
Can it call a function from outside in eof?

Time:04-12

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

CodePudding user response:

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$
  • Related