Reading Notes: SED and awk

Source: Internet
Author: User
Tags control characters printable characters alphanumeric characters

This book is devoted to the usage of SED and awk, which is very detailed and quite good.

Chapter 4 basic operations

1. awk and SED

2. Difference between SED and Ed

Sed is an implicit global command, while Ed only affects the current line.

Note: It is important to understand the difference between the current row addressing in Ed and the global row addressing in sed. In Ed, use addressing to expand the number of lines affected by the command line. In SED, use addressing to limit the number of lines affected by the command line.

3. awk Introduction

4. Sed and awk command line syntax

5. Use SED

In the SED command, the command can be caused by single quotes or not, but when the command contains spaces, you must use single quotes. The-e option is required when multiple commands are provided on the command line, which tells sed to interpret the next parameter as a command.

6. Use the script file in SED

Use the-F command to apply the commands in the script file to each line of the input file.

7. Run awk

8. command line options for SED and awk

 

Chapter 4 understanding Regular Expressions

1. POSIX characters

Class matching characters

[: Alnum:] printable characters (shortdes whitespace)

[: Alpha:] Alphabetic Characters

[: Blank:] space and tab characters

[: Cntrl:] control characters

[: Digit:] numeric characters

[: Graph:] printable and visible (non-space) characters

[: Lower:] lowercase characters

[: Print:] alphanumeric characters

[: Punct:] punctuation characters

[: Space:] whitespace characters

[: Upper:] uppercase characters

[: Xdigit:] hexadecimal digits

2. Common Regular Expressions

^ [: Space:] * $ only blank rows are included

^ $ Empty rows

^. * $ The whole row

In sed (and grep), only when ^ and $ appear at the beginning or end of a regular expression is special.

3. Specify the span and determine the span length in the regular expression.

4. Useful Regular Expressions

Chapter 4 writing sed scripts

1. Addressing Mode of SED

2. Use grouping COMMANDS IN SED

Chapter 1 Basic sed commands

1. Replacement command

2. Replace metacharacters

3. List

Chapter 4 compiling awk scripts

1. awk Programming Model

2. Record and Field

Chapter 3 conditions, loops, and Arrays

1. The conditions and loop statements referenced from C

If/if-elese condition selection statement

Conditional operator? :

While Loop

Do-while loop

For Loop: use it to traverse all fields of the record

Break statement: jump out of the latest Loop

Continue: end the current loop ahead of schedule

2. Array

Join Array

In awk, all arrays are associated arrays, And the subscript of the associated array is a string. Even if you give a number, awk converts it into a string.

Test the membership in the array

3. Use split to create an array

4. Delete array elements

5. System variable array

6. environment variable array

Chapter 2 Functions

1. arithmetic functions

Trigonometric function, integer function int ()

2. Random Number Generation

3. String Functions

Chapter 5 bottom drawer

1. Getline command

2. Close Function

Used to Close opened files and Pipelines

3. system functions

4. Direct output to files and Pipelines

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.