I am learning the bash function, and within the tutorial is the basic functions. My issue is that when I write the function on the terminal it works, but when I write it inside a .sh file and try to execute the function by its name it doesn't work
This is the terminal trails:
Input:
$ hello_world () { echo ' hello world this is 2021' ;}
run:
$ hello_world
hello world this is 2021
This is the hello_world.sh
$ vi hello_world2.sh
#!/bin/bash
hello_world2 () {
echo ' hello world this is 2022' ;
}
when I try to execute it I get this error:
$ hello_world2
zsh: command not found: hello_world2