Shell programming: before running shell script tracing and debug scripts, the most feared problem is the syntax error! So how can we debug it? Is there a way to determine whether there is a problem without directly running the scripts? Haha! Of course! Let's take the bash-related parameters for determination! C code [root @ www ~] # Sh [-nvx] scripts. sh option and parameter:-n: Do not run the script, only query syntax issues;-v: before running scloud, output the content of scripts to the screen;-x: displays the script content on the screen. This is a useful parameter! Example 1: Is there a syntax problem in the test sh16.sh? C code [root @ www ~] # Sh-n sh16.sh # If the syntax is correct, no information is displayed! Example 2: list all the running processes of sh15.sh ~ C code [root @ www ~] # Sh-x sh15.sh + PATH =/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin: /root/bin + export PATH + for animal in dog cat elephant + echo 'there are dogs .... 'There are dogs .... + for animal in dog cat elephant + echo 'there are cats .... 'There are cats .... + for animal in dog cat elephant + echo 'there are elephants .... 'There are elephants .... note that the running results in example 2 above are not displayed in color! For convenience, laruence adds color to the data after the plus sign! In the output information, the data after the plus sign is actually a command string. The command running process is also displayed in the sh-x mode, in this way, the user can determine which part of the Code will contain relevant information! This feature is amazing! By displaying the complete command string, you can correct your script based on the output error message! Familiar with sh usage will help you easily manage Linux! As for the Shell scripts learning method, you need to "read more, imitate more, and modify it into your own style !』 Is the fastest way to learn! There are quite a few friends on the network who are developing some very useful scripts. If you can use the other party's scripts, and change it to a suitable host! So the learning effect will be the fastest! In addition, we have many service startup scripts in Linux. If you want to know what functions each script represents? You can directly use vim to access the script. Generally, you will know the purpose of the script immediately. For example, we have mentioned the/etc/init. d/syslog file. Why is this script used? Using vi to check the first few lines of words, the following information appears: C code # description: syslog is the facility by which too daemons use to log \ # messages to various system log files. it is a good idea to always \ # run syslog. ### begin init info # Provides: $ syslog ### end init info simply put, this script starts a resident program named syslog (daemon ), this resident program can help many system services record their log files. We recommend that you always start syslog in Linux! Hey! You can see what it is!