Copy Code code as follows:
#!/bin/sh
# Get the first day of the quarter, the date interval 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= ' Expr
Copy Code code as follows:
#/bin/bash
# History
After #把以下代码直接粘贴到/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= ' hostname '
Fi
if [!-D
Shift can be used to move position parameters to the left.Shell's name is $The first argument is $Second argument $Nth parameter $nAll parameters $@ or $*Number of parameters $#
Shift default is shift 1Take the example below:
Copy Code code
Take a look at the contents of the original file:
Copy Code code as follows:
Root@localhost ~]# Cat File.txt
Hello World
A:b:c-h-N
A:b:c-h-N
SED deletes related rows based on conditions:
Copy Code code as follows:
The company's recent server testing, the need to constantly adjust the system time, one or two is ok half, a little more points, on a variety of entanglements, the author of these several sets of the author is going crazy. Eldest brother: All speed
Copy Code code as follows:
useradd.sh
#!/bin/bashFor name in Tom Joy John Mark JamesDo Useradd $nameecho "Redhat" | passwd--stdin $nameDone
OK, after the execution, the new user will be automatically created Tom, Joy, John, Mark, James,
The content of this section:Keep the specified number of files remaining under the file system
Example:
Copy Code code as follows:
#!/bin/bash
#-------------------------------
#Description: Back Up your files
#site: Www.jb51.net
#--
The problem is as follows
Input: Pointer to node C in list A->b->c->d->e
Output: no return value, but new list becomes a->b->d->e
Answer:
Thought for a long time did not think out, read the hint to know the solution. Here's a little trick. To remove
A: This script runs the machine, LinuxB: The machine that installs the JDK, Linux
First, on machine A on which the script runs, determine that you can log on to machine B on the JDK by SSH without a password, and then you can run this script on a:
The core server ran a bunch of scripts, procedures, it is inevitable that sometimes zombie process, dead or alive in the occupied resources there, initially just wrote a keyword to kill the process of the Linux shell script, and later found that
Copy Code code 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, according to the Gap group, Gap in accordance with GAP/2 decline
{
After the
Not long ago I saw two interesting commands in the book--script and Srciptreplay, which can record a terminal session in a file, that is, we can create a command-line video tutorial through a terminal session, or we can share session files with
The script is mainly from the defined NTP server list to get the server address to synchronize, if the first unsuccessful, will continue to change the address to sync! Not perfect place also please point out!
Copy Code code as follows:
#
The main purpose is to restart the background of more important processes, if the use of killall-9 forced kill, may cause problems. such as database processes. The code is as follows:
Copy Code code as follows:
#!/bin/sh
If [-Z "$"];
Shell Array Description:
Copy Code code as follows:
Array variable definition:
$ arr= (1 3 6 8 2 5 9 0 7 4)
Get first element by default
$ echo $arr
By subscript access, the second element of the array below, the shell array
In a multiple-machine cluster environment, often faced with the modification of the configuration file after copying to multiple servers, the traditional implementation of the SCP is troublesome, so write the following shell script, you can copy the
Recently saw a group of people chatting to their server has recently been Hung horse, and then want to use a script to monitor the Web directory changes in real-time files, that is, the directory of additions and deletions to the corresponding log
The IP that lists the most visited times of the daycommand:
Copy Code code as follows:
Cut-d--F 1/usr/local/apache2/logs/access_log |uniq-c | Sort-rn | Head-20
Principle:
Copy Code code as follows:
cut
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