CopyCodeThe Code is as follows: #/bin/bash
# History
# Paste the following code directly to/etc/profile.
User_ip = 'Who-u am I 2>/dev/null | awk '{print $ NF}' | sed-E's/[()] // g''
Histdir =/var/log/. hist
If [-Z $ user_ip]
Then
User_ip =
Shell logical operators involve the following types. Therefore, you only need to make proper selection to solve many complicated judgments and get twice the result with half the effort.
I. logical operators
Logical
Previous
We all know that Linux Shell is very powerful in text processing. There is a powerful set of text processing tools: grep, sed, awk. Grep is often used for searching and matching text and SEDCompositionThis edited replacement and awk are
Original article link
While read wone wtwo wthreeDo[-Z $ wone] & continue # test whether the content of this row is emptyXxx = $ wone # extract contentDone Echo "$ XXX" # The variable obtains the content in the file.
The following methods cannot
## Check the PID of such program#Checkpid (){If [-z "'ps X | grep $1 | grep-V grep | grep-V $0 | awk '{print $1}'' "]; thenEcho "the $1 program cant run well ."Fi}
Simple Description:
PS reportProgramStatus.
Ps x shows all programs,
1. Count the total number of rows of all common files in a directory
# Practical scenarios: when designing a graduation project, you need to calculate your ownCodeNumber of rows #
Solution 1:Find.-Type F-name"*. C"-Exec cat {}\; | grep-V'^ $'|
1. http://edsionte.com/techblog/archives/3712 echo and backslash
Group records:2. This is only a variable. Double quotation marks will prevent shell tokens from echo "a B" and echo a B.
3 --------
4 "a B" is a parameter of echo, while echo a B is
When it comes to shell wildcard (wildcard), it is often used. The following is an example:
#1
[chengmo@localhost ~/shell]$ lsa.txt b.txt c.old#2
[chengmo@localhost ~/shell]$ ls *.txta.txt b.txt#3
[Chengmo @ localhost ~ /Shell] $ ls d *.
It may have been a long time to stay in the shell, so that the current world is almost confused.This is the case when developers are busy with development and do not know the changes in the environment around them all day long. Maybe in
The Shell script is mainly used to initialize the new Linux server system, including:
Disable IPv6 ModuleDisable SELinuxShow vim colorsSet system language EncodingOptimize system servicesKernel Parameter optimization.It can be modified according to
Shell also has a real debugging mode. If an error occurs in the script "strangescript", you can debug it as follows:
Sh-x strangescript
This will execute the script and display the values of all variables.
Shell also has a mode that only checks
Copy codeThe Code is as follows: # include
Using namespace std;
Void ShellQin (int A [], int n)
{
Int gap = n/2;
Int I, j;
For (; gap> 0; gap = gap/2) // set the initial gap, group by gap, and decrease by gap/2
{
// After the gap is set, insert and
This e-mail alert script is widely used. Many of the sendmail and postfix scripts are used, and some of them are used in perl's NET: SMTP and Authen: SASL modules, but I am not using perl well. I always send some inexplicable emails (such as if (a> 1
Copy codeThe Code is as follows :#! /Bin/sh
# Obtain the date interval from the first day of the quarter to yesterday
# Link: www.jb51.net
# Date: 2013/2/28
Day = 'date-d "1 days ago" "+ % Y % m % d "';Year = 'expr substr $ {day} 1 4 ';Month =
1. Methods of raw violence
Copy codeThe Code is as follows: myLinux:/home/zhanhailiang/public_html # killall nginx
2. gentle approachFind the pid of the specified process and kill | kill-USR1
Copy codeThe Code is as follows:
Bash shell supports only one-dimensional arrays, but there is no limit on the number of parameters.
Declare an array:Declare-a array(In fact, you don't need to declare it. You just need to assign values to variables in the array mode. BASH knows
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.