Shell programming (ii) --- shell script description

Source: Internet
Author: User
Tags shebang

Script: the source program implemented by the command flow control mechanism based on the actual situation.


Script description:

1. Start with shebang, that is #! /Bin/bash. The path of the script interpreter is specified here. 2. Comments starting with # are used to describe the functions and functions of the script. 3. Script Execution: You can directly grant the X permission to the script and add it to the PATH variable by using the path where the script is located or the directory where the script is located. 4. If you run the script in SH mode, the script does not require the X permission, and the first line in the script does not need to write shebang.


Example 1:

[[email protected] Scripts]# cat deluser.sh#!/bin/bash#Version: 1.0#Author: Frame#Descrition: Add User#Define PATH VariablePATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin#add user user1 to user5useradd user1useradd user2useradd user3useradd user4useradd user5echo -n "user1" | passwd --stdin user1 > /dev/nullecho "User user1 add successful"echo -n "user2" | passwd --stdin user2 > /dev/nullecho "User user2 add successful"echo -n "user3" | passwd --stdin user3 > /dev/nullecho "User user3 add successful"echo -n "user4" | passwd --stdin user4 > /dev/nullecho "User user4 add successful"echo -n "user5" | passwd --stdin user5 > /dev/nullecho "User user5 add successful"[[email protected] Scripts]#


This article is from the "Hezhang" blog, please be sure to keep this source http://hezhang.blog.51cto.com/1347601/1435282

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.