Determine whether the shell script code exists in the file

CopyCode The Code is as follows :#! /Bin/sh # Determining whether a file exists # Link: www.jb51.net # Date: 2013/2/28 Mypath = "/var/log/httpd /"Myfile = "/var/log/httpd/access. log" # Here, the-x parameter determines whether $ mypath exists

Shell script used to record the use of commands after Logon

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 =

Linux Shell logical operators and logical expressions

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

Awk command learning summary and awk command series Learning (Linux Shell)

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

Shell reads File Content

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

Linux Shell check process PID

## 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,

A set of practical shell commands that may be frequently used in learning # update and learn slowly #

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'^ $'|

Shell variable setting and display

[Root @ localhost ~] # Echo $ {mail}/Var/spool/mail/root[Root @ localhost ~] # Echo $ {mail ###/*/} # pre-Greedy match DeletionRoot[Root @ localhost ~] # Echo $ {mail #/*/} # pre-match DeletionSpool/mail/root[Root @ localhost ~] # Echo $ {mail %/*} #

Single quotes and double quotes in shell

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

Introduction to Linux Shell wildcards, metacharacters, and escape characters

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 *.

Do not contract in the project or product "shell"

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

Share a simple Linux Server initialization Shell script

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

How to debug Linux shell scripts

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

Shell script code for automatically restarting the service

Copy codeThe Code is as follows :#! /Bin/bash If [! -F/tmp/down_count]; then Echo "0" & gt;/tmp/down_count Fi Curl-I tomcat-host-o "/tmp/status" & gt;/dev/null 2 & gt; & amp; 1 Code = 'awk' NR = 1 {print $2} '/tmp/status' If ["$ [code]"-ge 500]

Code for parsing shell sorting

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

Use shell + sendmail to implement the server Monitoring Alarm script

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

Get the shell script code for two date intervals

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 =

Kill the shell script code of a specific process

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:

Linux shell Array

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

Shell scripts for automatically logging on to multiple servers using reverse CT

Copy codeThe Code is as follows :#! /Usr/bin/CT-f Set ipaddress [lindex $ argv 0] Set passwd [lindex $ argv 1] Set timeout 30 Spawn ssh root @ $ ipaddress # CT "yes/no" # Send "yesr" Reset CT "password :" Send "$ passwdr" CT "] *" Send

Total Pages: 541 1 .... 401 402 403 404 405 .... 541 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.