Linux self-study note--vim and text Three Musketeers Foundation

Source: Internet
Author: User

1. Regular expressions

(1) Extension: Unlike grep, egrep or grep-e do not need to be added \ Escaped

(2) Character matching

.: Matches any single character

[]| [^]: matches any single character outside the specified range |

(3) Number of matches

*: Any time {0,}

\?: 0 or 1 times {0,1}

\+: At least 1 times, at most {1,}

\{n\}: N times   

\{n,b\}: N to B Times

\{n, \}: At least n times, up to No limit

(4) Position anchoring

^: Beginning of the line $: End of line ^...$: Whole line

\<: The first word \>: Suffix \<...\>: Whole word

(5) Grouping

\ (\): Multiple characters are treated as a whole, and can be referenced with \1...\n

2.vim

(1) configuration file:/ETC/VIMRC

(2) Common configuration: Set Nu,set nonu,set hlsearch,set Nohlsearch

(3) Input mode

I: Insert at cursor position I: Inserting at the beginning of the line A: Inserting at the end of A row

o: Insert at cursor location O: Insert on the upstream of the cursor

zz|wq,q!: Save off, do not save close

(4) Cursor Jump

Word Jump W: Jump to the next word First E: Jump to the beginning of a word

in-line jump ^: Beginning of $: End of line

Inline Jump 1g|gg: Wen shou G: Wen Mei #G: Specify Rows

(5) Delimiter

%: Full text $: End of text.: Cursor #,#: Specify range

(6) Edit command

Cut d^: To the beginning d$: to the end of the line DW: Word

DD: Whole line #dw: multiple words #dd: Multiple lines after the cursor

d1g: To the head DG: to the end of the text %d: Full text 1,$: Full text

., $: Cursor at the end of the text

Copy y: Mode with delete

Paste P:d is cut instead of deleted, so d can be pasted directly after P

Replace delete s/grep/Replace, empty to delete/{i ignore case, G full text Replace}

Read File R/path/file

3.sed

(1) Output sed-n ' 1,3p ' constant and silent mode-n with

(2) added sed ' $a append ' sed ' 1i Insert '

(3) Remove sed ' 1, $d '

(4) line replacement sed ' 1, $c newbody '

(5) string substitution sed ' s/grep//g ' with vim replacement

4.awk

(1) Variable NF: Total number of fields NR: Number of rows processed FS: delimiter

(2) Filtering awk '/grep1/,/grep2/'

(3) Split awk-f ': '/grep1/{print $ '

awk ' {fs= ': '}/grep1/{print '

Note that the/grep/match cannot be placed in {}        

(4) Condition awk-f ': ' $1>100{print $ ' note condition if no if () cannot be placed in {}, it can not be used concurrently with/grep/, plus if (), for example:

Awk-f ': '/grep/{if ($1==1) {Prit $}} '

Linux self-study note--vim and text Three Musketeers Foundation

Related Article

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.