Want to learn the "three Musketeers" the most basic or regular expression of proficiencyThe complete collection of regular expressionsFormat of the Log2018/10/03 23:59:14.944 adapter.go:353: [warning] [SLOW_QUERY] cost_time:111.420169ms succ:true connection_id:0 txn_start_ts:403375431254540289 database: table_ids:[21] index_ids:[1] sql:select tab_id, is_ind, hist_id, distinct_count, version, null_count, tot_col_siz from mysql.stats_histograms where table_id = 40373...
Some nonsense:For regular expressions, always like to understand not understand, see some code, script regularly,awk,sed. The heart is always a bit empty. I can't remember the main. Usually not how to use, also did not summarize. Now have time, decided to summarize, by the way to overcome the see shell,js These with regular on the weakness of the guilty. I'm going to write three essays.Text :Generally speak
Using of grep sed awk on Linux, grepawk
# This script is to parse data file:
Fun0 ()
{
##[INFO1]A = 1 B = 2 c = 3[INFO2]A = 7 B = 8 c = 9[INFO3]A = x B = y c = z
}
#! /Bin/bashRead Info Abc# Echo $ InfoIf ["$ Info "! = "INFO1"-a "$ Info "! = "INFO2"-a "$ Info "! = "INFO3"]ThenEcho "Wrong INFO! "Exit 0FiSed '/^ # \ | ^ $/d' $1 |
"
\{n,\}
matches the previous line with the last character repeat number at least n times
\{n\}
matches the line with the previous character repeated n times
example 1:[[email protected] tmp]# grep"^th"Regular_express.txt ThisDress doesn't fit me.example 2:[[email protected] tmp]# grep"y$"Regular_express.txt"Open Source" isa good mechanism to devo
Tag: enter lang \ \ Keep www www. How to enter blankAs follows: How to delete blank linesShen\nshen\\nsensehseheshesheTo really delete empty lines, you can use VIM:
Delete empty lines through command mode. Vim in command mode (enter English characters in vim: Enter command mode) input: %s/^n//G. replaces all characters that begin with a carriage return, substituting null.
If you have more than one contiguous blank line, you want to keep a row. Then simply enter the following li
the beginning and end of a word
Demo results650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/85/A8/wKiom1erK9KTmXhgAAB0GJE0uWc768.png-wh_500x0-wm_3 -wmp_4-s_1012968505.png "title=" 3.png "alt=" Wkiom1erk9ktmxhgaab0gje0uwc768.png-wh_50 "/>Example:Use the following command to find the No and standard IP numbersGrep-e ' [1,2][0-9]{0,2}\. [0-9] {1,3}\. [0-9] {1,3}\. [0-9] {1,3} ' exeLooking for a standard mobile phone numberGrep-e ' 1[34578][0-9]{9} ' exeSearch for No and stand
Grepqueries/extracts rows that contain specific keywords from the data file.SedUsed primarily for substitution processing of specific strings in a data file.CutCuts the contents of the selected column (-F num) or the character (-c) by the specified delimiter (-D).AwkOften used to display only specific fields, or to rearrange the order of fields in a row.JoinA file used to combine fields with a common key value in a record.---------------------------------------------------------------I'm a split
Regular expressions: Regular expressions are a set of rules and methods that are defined for processing a large number of strings.Regular expressions are widely used in almost all languages (e.g. Java, C, C + +, PHP, Python, etc.)============ Basic Regular =============^ Match with what to start with, ^w matches content starting with W$ match with what ends, $w matches content ending with W^$ Matching Blank lines. Represents and can only represent any one character\ escape character, such as \.
Use the shell command in combination with grep awk sed sort # when processing a ticket, select the desired ticket first. Here, select the AAA ticket, then sort by corresponding fields # The-k parameter is generally used, and + 0.4 is generally used when the file name is relatively regular
Jul 03:21/root/oldboy.txt 1.5 write up the previous directory CD command 1) go to the previous level directory CD .. 2) View multiple top-level directory CDs: /.. /.. /.. /.. /.. /.. / 3) Enter the current directory CD Chapter 2nd the use of the Three Musketeers of Linux 2.1 grep (filter) Three Musketeers old three Method 1-grep [[emailprotected] data]# #grep
[[Email protected]~]# cat File1 2 5 8 9[[email protected]~]# cat file |xargs-n1[[email protected]~]# xargs-n 1 This article is from "Kaka West" blog, please be sure to keep this source http://whnba.blog.51cto.com/1215711/1853501Methods such as grep, SED, and awk implement row-to-column
Common Uses of sed:Common Uses of awk:Common Uses of grep:In addition to listing compliance lines, and listing the next 10 lines.Grep-a Exception Kzfinance-front.logIn addition to listing compliance lines, and listing the first 10 rows.Grep-b Exception Kzfinance-front.logIn addition to listing compliance lines, and listing 10 rows before and after.Grep-c Exception Kzfinance-front.logDetailed reference:http://blog.csdn.net/xiaokang06/article/details/29880465Sed
Tags: linu lis $ padding pre row to column strong invalid forRow to columnThe sample file is as followsCat File.txta B CD e FG H i
cat file.txt |xargs -n1
xargs -n 1
tr " " "\n"
4.sed 's/ /\n/g' file.txtThis command works on Linux and does not work on Mac because sed on Mac is BSD version, GNU version on Linux, need to use on Macsed -e 's/ /\'$'\n/g' file.txt5.
.$: Contains the text content of the first field.awk ' {print $} ' filename prints the fifth column.Print permissions and file names for files in the current directory:awk ' {print $ ': ' $9} 'Total-rw-rw-r--.: BsdmakefileDrwxrwxr-x.:config-rw-rw-r--.: config.inDrwxrwxr-x.:d OCSDrwxrwxr-x.:feeds-rw-rw-r--.: Feeds.conf.defaultTo remove a sentence that contains a word in a file:Sed ' s/[^.] *mobile phone[^.] *\ . G ' filenameRemove the sentence that contains the word "mobile phone".The format of t
Text processing cat more less head tail sort uniq grep cut jion sed awk################################################cat:concatenate files and print on the standard output display the contents of the file to the normal outputs (display)-E: Displays the last character at the end-N: Show line numbering[Email protected] ~]# cat-n/etc/shells1/bin/sh2/bin/bash3/sbin
files that include W and tGrep-e "W*t" fileFind rows greater than 560 less than 893 in file filesGrep-e "[5-8][6-9][0-3]"Find a row with two 9 in a fileGrep-e "9{2}" fileFind rows that are larger than two 9Grep-e "9{2,}" fileFinding blank lines in a fileGrep-e "^$" fileFind included? The linegrep "?" FileFind lines in a file that start with WGrep-e "^w" fileFind rows in a file that are not preceded by WGrep-e "^[^w]" fileawk Data Flow processing toolFind each column in the log fileawk ' {print
Regular expressions: Regular expressions are a set of rules and methods that are defined for processing a large number of strings.Regular expressions are widely used in almost all languages (e.g. Java, C, C + +, PHP, Python, etc.)==================== Basic Regular =====================^ Match with what to start with, ^w matches content starting with W$ match with what ends, $w matches content ending with W^$ Matching Blank lines. Represents and can only represent any one character\ escape charac
1. grep1, 1 grep [-INVC] [--color=auto] ' search string ' filenameOptions and Parameters:-I: Ignore different case-n : Output line number by the way-v : Displays rows without a ' search string '--color=auto: Add color to the found part-C: Count the number of rows found-A2: Matching line and 2 rows below it-B2: Matching line and 2 rows above it-C2: Matching line and 2 rows above itgrep and regular expressionsGrep-n ' ^$ ' file #空白行Special charactersLin
A regular expression: a regular expression (or regular expression, called re) is a text pattern consisting of ordinary characters (such as characters A through Z) and special characters (called metacharacters). This pattern describes one or more strings to match when looking up a text body. A regular expression, as a template, matches a character pattern to the string you are searching for. Simply put, the regular expression is the method of processing the string, it is the behavior unit to cond
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.