Current location - Health Preservation Learning Network - Healthy weight loss - Mac OS terminal running. Sh script.
Mac OS terminal running. Sh script.
1. Edit the script file. For example, test.sh is saved in the/users/computername /Documents directory. Content:

Echo "hello";

2. Open the terminal and run cd /Users/ computer user name/document to enter the directory;

3. Run test.sh directly;

If a -bash: test.sh: command not found error appears, please set the path:

Export path =$PATH:/Users/ computer user name/document

Sometimes you will be prompted-bash: test.sh: There is no such file or directory. You can also run the signed command and set the path to solve it.

Run it again, and you can see hello on the console!

If it doesn't work, try chmod u+x test.sh to improve file permissions before running the script.