How to run the. sh file under Linux
This article describes a method of how to run. sh files under Linux with commands, in two ways:
First, direct./plus file name. SH, if running hello.sh for./hello.sh "hello.sh must have x permission"
Second, direct sh plus filename. sh, such as Run hello.sh for SH hello.sh "hello.sh can have no x permission"
Tools/Materials
Method One: The current directory executes the. sh file
- 1
"Step One" CD to the directory where the. sh file is located
For example, in the case of hello.sh files, such as
- 2
"Step Two" Add x Execute permissions to the. sh file
For example, take the hello.sh file as an example, chmod u+x hello.sh, such as
- 3
"Step three"./execute. sh file
For example, in the case of hello.sh files,./hello.sh can execute hello.sh files, such as
- 4
"Step four" sh execute. sh file
In the case of the hello.sh file, sh hello.sh can execute the hello.sh file, as
END
Method Two: Absolute path execution. sh file
- 1
The following three ways are available, such as
./home/test/shell/hello.sh
/home/test/shell/hello.sh
sh/home/test/shell/hello.sh
END
Precautions
- Use "./" To add the file name. SH Execute, must give. sh file plus x Execute permission
- If you have the help, help "get", help you are our greatest motivation for progress!
- If you like, please click "Vote", your participation is our greatest motivation for progress!
- If you have questions, please submit a question, and your interaction is our greatest motivation for progress!
- For reference only
How to run the. sh file under Linux