First shell program: Hello World

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.