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