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 =

Analysis of Shell custom functions and parameter calls

I. define functions CopyCodeThe Code is as follows: function fname () { Statements; } OrCopy codeThe Code is as follows: fname (){Statements;} Ii. Call Functions You can call a function by using the function name:$ Fname; # execute a

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

Linux shell provides two methods to obtain a single character in the specified range of user input.

Method 1: Copy codeThe Code is as follows: echo 'echo {a. z} ''echo {A. Z}'>/tmp/letterfile While read-p "please input a letter:" letter Do ('Awk-v var = "$ letter" 'In in {print length (var)} ''= 1 )) & grep-q $ letter/tmp/tmpfile & break Done Rm-f/

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 =

Extract the shell script code of alert log On oralce

Extract the alert log shell script of oralce on the current day Copy codeThe Code is as follows: #/bin/sh # Get alert of everyday # Then name of file is everyday_alert.sh Dir = "/oracle/admin/bbdz/bdump" Num = $ (cat-n $ {dir}/alert_bbdz.log |

Back up the shell script code of the website content

Back up website content Copy codeThe Code is as follows :#! /Bin/bash # Specify the running script shell # Run the script to grant the user the execution permission Bakdir =/backup Month = 'date + % m' Day = 'date + % d' Year = 'date + % y'

Tips on shell programming

1. print some header informationCommand ............Dilimiter Use the content in the demarcation symbol dilimiter as the standard input of the commandIt is often used in echo commands, which avoids the use of an echo command when no line is output,

A shell script used to count the hard disk usage of CPU memory

Copy codeThe Code is as follows :#! /Bin/bash # This script is used for describle CPU Hard Memery Utilization Total = 0 Idle = 0 System = 0 User = 0 Nice = 0 Mem = 0 Vmexec =/usr/bin/vmstat Which sar>/dev/null 2> & 1 If [$? -Ne 0] Then Ver = 'vmstat-

Introduction to linux shell udfs (definitions, return values, and variable scopes)

1. define the shell function (define function) Syntax:[Function] funname [()]{Action;[Return int;]}Note:1. It can be defined with function fun () or fun () without any parameters.2. If the parameter is returned, the value "+: return" is displayed.

Shell script for real-time file shunting in the background

Copy the files in the bill folder to the bill1 and bill2 folders according to certain rules (file name parity.Update the progress tag of bill1 and bill2 (Update file. max)File3 is the label of the latest file under the bill directory. It is updated

Shell script code for concurrent database stress testing

Copy codeThe Code is as follows :#! /Bin/bash #********************************# # Run fun in the concurrent background # # For wanggy 2012-01-25 # # Note :# # Fun_num number of times the fun function runs in the background # # SQL _num SQL

Shell script for sending LOG Category numbers via SMS

Copy codeThe Code is as follows :#! /Bin/bash # Telno is used to query the number list file # Sendsms. log is the text message sending result File #1 indicates that the message is successfully sent. Query_sms () { > Submit_telno >

Bash Shell script learning Summary

1. Character truncation: For normal path truncation, you can use the basename and dirname tools:Basename can intercept a file name from a file path. For example: Copy codeThe Code is as follows: $ basename/home/file.tar File.tar Dirname can be

Prevents repeated code execution by shell scripts

For example, to require scripts to only access a certain resource in sequence, such as disk files, you can refer to the following implementation. Copy codeThe Code is as follows :#! /Bin/bash # # File locking using bash. # Ver 0.1.6 # # Author:

Introduction to shell comparison

Compare shell strings and determine whether the string is a number Binary comparison operator, which compares variables or numbers. Note the difference between numbers and strings. Integer comparison -Eq equals to, for example, if ["$ a"-eq "$ B"]

Total Pages: 541 1 .... 484 485 486 487 488 .... 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.