Today on the Internet to see a web connection average time of the shell command, in their own machine tried, found that can not use, incredibly appear awk:fatal:division by zero attempted such a mistake, Mao's own changed the shell command.Original
The shell script is so powerful that it always touches the tip of the iceberg.
Shell recursively traverse directory
#!/bin/bashecho "Please input the directory:"Read CdirFor Dir in $ (find $cdir-type D); Todoecho Change to $dirCD $dirLsecho "------
The IF statement in the shell needs to make a regular judgment and check the grammatical records.
The code is as follows
Copy Code
Datepattern= "^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$"if [["$STARTDATE" =~ $DATEPATTERN]] && [[
Here's a simple shell program to illustrate.
debian:~/learn/shell# Cat Phonebook
Alice Chebba 973-555-2015
Barbara Swingle 201-555-9257
Liz Stachiw 212-555-2298
Susan Goldberg 201-555-7776
Susan Topple 212-555-4932
Tony Iannino
Part 1: ' Command '
This is the "command standard output as a function of standard input" method of operation, there are great drawbacks and unsafe places.
disadvantage one: relatively old.
disadvantage two: easy to confuse with single quotes.
This is the 8th/101 script
There are as many ways to solve this quirky echo problem as There are the pages in this book. One of my favorites is very succinct:
function Echon
{
echo ' $* ' | awk ' {printf '%s ' $} '
}
You could prefer to
The shell case is simpler, but it has its characteristics.
#!/bin/sh
# scriptbc-wrapper for ' BC ' which returns the result of a calculation.
if [$ = ' P ']; Then
precision=$2
shift 2
else
precision=2 # default
fi
bc-q
Script
Shell string Comparisons, judging whether it's a number
Binary comparison operator, comparing variables or comparing numbers. Note the difference between numbers and strings.
Integer Comparisons
-eq equals, such as: if ["$a"-eq "$b"]
-ne is
One, the definition function
Copy Code code as follows:
function fname ()
{
statements;
}
Or
Copy Code code as follows:
FName ()
{
statements;
}
Second, call function
You can call a
Copy the files under the Bill folder to a certain rule (file name parity) under the Bill1,bill2 folder.Update BILL1,BILL2 Processing Progress tab (update File.max)File3 is the label for the current latest file in the bill directory and will normally
First, create a expect script ssh_expect, which reads as follows:
#!/usr/bin/expect-f
set hostname [lindex $argv 0]
set user [lindex $argv 1]
set passwd [lindex $argv 2]
s Et timeout
set force_conservative 1
if {$force _conservative} {
set
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
Embedded beginners, the first time to upload code. Yesterday did a UDHCPD and Udhcpc Guardian, currently only with Shell imitation writing, what method can do guardian?
#! /bin/sh
#进程名字可修改
pro_name=udhcpc
wlan=ra0 while
true;
# get
To create a random number method:
Copy Code code as follows:
1~~~~
/dev/urandom
In Linux, a device/dev/urandom is used to generate random sequence of numbers. Using this device we can generate random strings when needed.
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 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