I. Script structureThe script for the shell under Linux is to write a series of command sequences in a text file, and this text file can be executed. Development efficiency increases relative to the command line. So his architecture has 2 parts that
I. DEFINITION of format[Function] Function name (){Command table}Ii. Method of InvocationFirst define, then use, direct input function name, no parentheses required ()Three, function parameter transfer methodCan be passed using positional parameters
My original intention in this article was to remove the "copy SSH Channel" and "Copy ssh Session" functions from the remote SSH client. So I thought I could set it up on the SSH server, but looked at the Sshd_config man Manual, It is found that the
In the shell, arguments can be passed to a function when it is called. Inside the function body, the value of the parameter is obtained in the form of a $n, for example, $ $ for the first argument, and $ = for the second argument ...Examples of
Original: Http://note.youdao.com/share/?id=cd2ad6e6d5db2b347f92958efc2bdbc1&type=noteRegular expressions and wildcard characters:First, Introduction:1. A regular expression is used to match a string in a file that matches a condition .contains
1. Explanation: A single string that describes or matches a series of strings that conform to a certain syntactic rule.Action object: StringMany are used in document editors or other tools to retrieve and replace text content that conforms to
About redirectsAdditional redirection operatorsUse set-c collocation Posix shell : execute set -c command to open shell The so-called forbidden override option simple > redirect encountered when the destination file already exists
Cut is a selection command:is to analyze a piece of data and take out what we want. In general, the selection of information is usually for "line" to analyze, not the entire information analysis.(1) The syntax format is:cut [-bn] [file] 或 cut [-c] [
A related knowledge 1) By default, the standard input is the keyboard, but it can also come from a file or pipe (pipe |). 2) By default, the standard output is terminal (terminal), but can also be redirected to a file, pipe, or post quotation mark
Shell script (vi)(2) awkA, awk programming mode#awk编程模式分三个阶段: Execute code Snippet before reading input file (identified by the BEGIN keyword)Execute code snippet after #读取输入文件时执行代码段, reading input file (identified by end keyword)B, pattern matching#
Test file
cat >testjasonjasonjasonfffffPress CTR + D to save1, Sort-usort -u testfffffjason2, UniqUniq TestjasonfffffjasonThis shows that Uniq needs to be sorted before it can be re-3, sort, pipe and uniq combined use
Remove duplicates
$# 是传给脚本的参数个数$0是脚本本身的名字$1 是传递给该shell脚本的第一个参数$2是传递给该shell脚本的第二个参数[email protected] 是传给脚本的所有参数的列表$* 是以一个单字符串显示所有向脚本传递的参数,与位置变量不同,参数可超过9个$$ 是脚本运行的当前进程ID号$? 是显示最后命令的退出状态,0表示没有错误,其他表示有错误
Difference:@*
Same point: All parameters are
ls command file, directory Operation commandLS Displays the current directory by defaultLs-a Show All Files hidden filesLs-l Display file propertiesLS-LH Display File sizeLs-lt display files sorted by modified time
cd Command Change
Chapter II Shell ProgrammingThe following sections are described in this chapter:What is a shell?Basic ideasSubtle syntax: variables, conditional judgments, and program controlCommand ListFunctionExecution of commands and commandsHere
Introduction to the sceneUse Cygwin under Windows, use Apktool to repackage apk; Way OneCD D:CD path/to/apk/in/dApktool D name.apk Way TwoDrag the file into the Cygwin window to delete the trailing file nameCTRL + ACD SPACEApktool D name.apk Mode
Shell script checks the memcache process and automatically restartsRevised version:#! /Bin/sh# Check memcache process and restart if downMm_bin = "/usr/local/bin/memcached"Mm_log = "/home/xxx/memcached_check.log"Mm_ports = ("11211" "11212 ")Mm_param
Online troubleshooting commands-Shell1. track online logs and regularly refresh the latest content: tail-fn 200 $ log 2. search for a specified String # only show the matched row grep $ String $ file # match the upper and lower lines of the String
Automatically download the source code _ and compile _ package _ deployment _ restart the service Shell script, source code shell
For the meaning of Shell operations, refer to my article three years ago:Http://blog.csdn.net/jadyer/article/details/796
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.