I've been studying this Linux shell program recently because I'm interested in this Linux system, so I've learned the shell programming at once.In fact, this Linux shell programming is a summary of the execution of this overall command, that is, if
Special characters
Purpose
Description
$ Variable
Get the value of a variable. If it is not initialized, It is null.
Returns the value of "variable". If it is not initialized, null is returned.
$
The while loop is applicable to scenarios where the number of loops is unknown.Syntax format: While conditiondo statement ...... Done Note: While is used to execute a loop when the condition is set up. When the condition is invalid, the loop is
#! /Bin/bashA = $1 # pass the first command line parameter to variable A, and the second command line parameter to BB = $2If [-Z $ A] | [-Z $ B] # determines whether a and B are empty. If one is empty, print the prompt statement and exit.ThenEcho
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 =
Every time you create a new script, you must add # In front of the script #! Some fixed text such as/bin/bash. The bash Script Creation script can automatically add information such as Bash and date author. After the creation is complete, the system
After openvswitch 2.1.2 is installed, it is often possible to start and stop. To avoid repeating the script to start and stop the terminal code, it is best to write it in a different script to facilitate the next call. The premise is that
A variable is a memory space. When a variable is referenced by a variable name, it is called a named memory space.
To define a variable, assign a fixed memory space to the variable. assign a value to the variable, that is, fill the data in the
I am often very lazy. The main solution to laziness is to use scripts for automatic execution. However, sometimes, for example, processing a piece of data has not been completed, and the next execution starts again, this is a problem. Let's see how
Jiebao
Jiebao
Jiebao
Jiebao
Jiebao
This series of scripts has already opened a forum on GitHub. I name it "Easy shell" (Click here to enter ).
At present, you have added the scripts in the previous phases. More scripts will be added to
Tag: Shell
1. Search for all files larger than 500 mb in the current directory, write these file names to a text file, and count the number of files.
Find/-size + 500 m-type F | tee/root/file.txt | WC-l or find/-size + 50 m-exec ls
Alias LL = 'LS-al'Use_color = false# Set colorful PS1 only on colorful terminals.# Dircolors -- print-database uses its own built-in Database# Instead of using/etc/dir_colors. Try to use the external file# First to take advantage of user additions.
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 =
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
>
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
Environment: 2 kserver + iis5 succeeded. The default permission is iusr.
Iis permission: script executable Description: by default, the server. createobject method can be used to use installed components on 2 k servers.
For example, we all know
Before capturing signals, you must first understand how to use kill:
Kill-l view Signal
650) this. width = 650; "title =" kill-l.jpg "src =" http://www.bkjia.com/uploads/allimg/131227/2315524596-0.jpg "alt =" 225340553.jpg"/>
Usage:
Kill-NUMBER
[Shell] judge the current user
Determines whether the current user is root. If the user is a root user, if not
#!/bin/bash#title: testus.sh#author: orangleliu#date: 2014-08-09#desc: get current user, if it is root user, tell us it is super user or
Overview
Multiple duts are usually used during testing, saving a lot of time to upgrade the new version of the work script.Code
#! /Bin/bash # download new version, scp to dut and upgrade # author: godlaughing url = $1 wget $ url download_dir
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