1. Get the file name of the current script, including the path.
Copy Code code as follows:
#写一个测试脚本
Vim test.sh
#内容如下
Dirname$0
Basename$0
#执行一下
bash$ (PWD)/test.sh
#输出如下
/home/jane
test.sh
2. $n get the
Create 500,000 files first
Copy Code code as follows:
Test for I in $ (seq 1 500000)
For> do
for> echo Test >> $i. txt
For> Done
1 RM
Copy Code code as follows:
Test Time Rm-f *
Zsh:sure you want to
Linux hardware devices in the/dev directory, the optical drive is one of them./dev/cdrom represents the optical drive, the method of mounting the optical drive is as follows (in root):
Copy Code code as follows:
Mkdir/mnt/cdrom
Uninstall and remove the WScript component
Wscript.Shell can invoke the system kernel to run DOS basic commands, which is harmful to system security. We're going to uninstall and remove the component to prevent this kind of trojan from
Use the shell to quickly generate a sitemap map file in XML format, which is suitable for small and medium sized websites. In this case, a sitemap file with 12,053 URLs is generated and only spents 4.3 seconds! The shell code is as follows:
Copy
Learn to use shell analysis log only one morning!!!
Many places to share the log analysis of the shell script, but basically did not say the specific meaning of each command, learning cost is very high, summed up here, to facilitate the quick start.
#!/bin/sh #测试各种字符串比较操作. #shell中对变量的值添加单引号, the difference between the hot quotes and the not added: it is irrelevant to the type, that is, not adding quotes into the string type, #单引号不对相关量进行替换, if the $ symbol is not interpreted as a variable
A shell script, what is its command parameter?First, shell scripting and scripting like Python can use parameters as well;Secondly, the shell parameters are divided into positional parameters and internal parameters;Where, positional parameter: is
Recently more busy, for a long time did not update the blog, today is not busy writing a traffic monitoring script. The test has passed under the CentOS, has the need friend to try, has the bug or needs to add other function words can leave a
Now in order to save money, I used a shell script, simply write a monitoring. By Curl a fixed page of 200 status code, if it is 200, said the site is normal, if not 200 automatically restart the site, and then send mail to QQ mailbox. QQ on their
1, edit the user's home directory of the. muttrc file, set the letter environment.
Copy Code code as follows:
# CAT/ROOT/.MUTTRC
Set Envelope_from=yes
Set from=owinux@sina.cn
Set Realname= "Owinux"
Set Use_from=yes
Set Rfc204
Each open file is assigned a file descriptor. stdin (keyboard), stdout (screen), and stderr (Error message output to screen) are the file descriptors 0, 1, and 2 respectively. The descriptor 3 to 9 is retained for the extra files that are being
A large number of files are required for testing, so a script is written to copy. A regular file name facilitates reference.
Copy Code code as follows:
#!/bin/sh
# file Name:batchcp.sh
# Author:zhouhh
#
With the need to monitor some of the Apache servers that require high availability, in addition to professional monitoring and alerting devices, it is a good idea to write a script that automatically monitors Apache status on the Apache server at
Sometimes in the Linux operating system to calculate the length of a string, through the query data to the current shell to get the length of the string of various methods to share here, the method is as follows:
Method 1: Use the wc-l commandWc-l
You must have seen the effect of flying words on a Web page, but how do you implement the Echo string in a Linux system, especially in Bash command line mode, with flying effects? This effect is not practical, but occasionally to amuse themselves
We will use the common system security configuration as a shell script, only to run this shell script on the server to complete the security settings.
Linux system security Settings Shell script is the second update, has been heavily used in a
Nowadays many people like to use spaces when they are named, such as "an Introduction.doc". But this naming problem is confusing to Linux command-line tools and shells, because most commands use whitespace as a separator between values and values,
1. Code is simple, but difficult to verify, not as good as Python understandingIt is recommended to edit under notepad++.2. Note the ' Yes ' tab key that references the Linux command.3.if[] HereError:syntax error near unexpected tokens ' then 'Cause:
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