1 shell script must have the read and executable (RX) permissions.
2. Differences in script execution methods:
1) Sh script_name or./script_name: execute in the sub-process (a new bash environment)
2) Source script_name: executed in the parent process
Tip: After the sub-process is complete, all the variables or operations in the sub-process will end and will not be passed back to the parent process.
3 Script Programming habits
1) Description of program content: script usage, author, creation date, etc.
2) Declaration of major environment variables: such as path and Lang
3) make comments as appropriate
4) 2/4 indent
4 Hello World
[root@localhost Desktop]# mkdir think[root@localhost Desktop]# lsthink[root@localhost Desktop]# cd think[root@localhost think]# vim shell01.sh
#! /bin/bash#program:#the program is for outputting "hello world"#history:#date 2012/9/5 autor think version 1stPATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin#begin programecho -e "hello\fworld \n"exit 1
[root@localhost think]# chmod +rx shell01.sh[root@localhost think]# ./shell01.shhello world [root@localhost think]# echo $?1