How the Shell script to write

Source: Internet
Author: User

Write Shell script:

1) Editor like VI or Mcedi

2) Set Execute permission for your script

chmod permission Your-script-name

chmod +x your-script-namechmod 755 your-script-name

  This would set read write execute (7) permission for the owner, for group and other permission are read and execute only (5).

 

3) Execute Script

      Bash your-script-name
      SH your-script-name
      ./Your-script-name

In the last syntax./means current directory, and only. (dot) means execute given command file in current shell without starting the new copy of the shell.

Example:

. Foo

 4) Practice

1 $ vifirst 2 #3Shell  script4 #5  Clear6echo "knowledge is Power"
1$VI ginfo2#3#4# Script toPrintUser information who currently login, currentDate& Time5#6 Clear7 Echo"Hello $USER"8 Echo"Today is \c";Date9 Echo"Number of User login: \c";Who | wc-lTen Echo"Calendar" One Cal A Exit0

How the Shell script to write

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.