I. Learn the knowledge reserve of shell programming
1. Related Linux system command applications;
2. Familiar with VI/Vim editor and related client software settings;
3. Basic services: NTP, crond, and network services: NFS, rsync, inotify, sersync, ssh, and lanmp.
Supplement: three methods for clearing logs:
1) echo ""> filename. Log
2)> filename. Log
3) CAT/dev/null> filename. Log
Note: You cannot delete (log) files at work, but can only clear the files!
2. Create and execute shell scripts
1. The first line of the script is generally :#! /Bin/bash or #! /Bin/sh;
2. execute shell scripts using bash script-name or sh script-name;
3. Execute the script in the current path. The shell script usually uses./script-name.
Shell script execution instructions (recommended ):
Example: 00 00 ***/Bin/bash/Server/scripts/bak. Sh>/dev/null 2> 1
III. Basic specifications and habits of shell script Development
1) Specify the script interpreter at the beginning
#! /Bin/sh or #! /Bin/bash
2) Add the copyright feature author and other information at the beginning
# Date:
# Author:
# Mail:
# Function:
# Version:
Tip: The above information is automatically added when you configure Vim to edit a file by modifying ~ /. Vimrc configuration file.
3) Chinese comments are not required in the script.
Try to use English comments to avoid Chinese garbled characters on the local machine or after switching the system environment.
4) The script uses. Sh as the extension name
5) Excellent coding habits
1. Write the paired content once to prevent omission;
2. [] There must be spaces at both ends of the brackets. When writing, you can leave a space [] and then write the content in the backspace;
3. After a flow control statement is written, add the content;
4. Make the code readable by indentation.
This article from the "empty valley orchid" blog, please be sure to keep this source http://2489843.blog.51cto.com/2479843/1539565