The file can not be executed immediately after the completion of editing the file, set executable permissions to the file. Use the following command.
[root@localhost bin]#chmod +x date
Shell program execution
Shell There are three ways to perform the following procedures:
method one:
[root@localhost bin]#./ date
Mr.root,Today is:
Monday, March 30
Wish you a lucky day !
Method Two:
Another way is to execute the date it passed as an argument to the command Shell:
[root@localhost bin]# Bash date
Mr.root,Today is:
Monday, March 30
Wish you a lucky day !
Method three:
In order can be compiled in any directory and execute programs written for Shell, which adds / bin directory of the entire environment variable.
Specific operation is as follows:
[root@localhost root]#export PATH=/bin:$PATH
[root@localhost bin]# date
Mr.root,Today is:
Monday, March 30
Wish you a lucky day !
Example: Writing a Shell program mkf, the function of this program is: Display the files in the root, and then create a folder kk, aa establish a file in this folder, modify the permissions of this file is executable.
Analysis: This Shell program you need to run the following command:
Into the root directory: cd / root
Display the files in the root directory: ls -l
New Folder kk: mkdir kk
Enter the root / kk directory: cd kk
Create a new file aa: After vi aa # manually edited to be saved
Aa file permissions to modify executable: chmod + x aa
Back to the root directory: cd / root
Thus the order of more than just a collection of Shell program commands, the program name is assumed mkf
[root@localhost root]#vi mkf
cd /root
ls -l
mkdir kk
cd kk
vi aa
chmod +x aa
cd /root