Unix & Linux University Tutorials (iii): filters,

Source: Internet
Author: User
Tags diff locale posix split words

16th Chapter Filter: Introduction and basic operation

Delete data column with COLRM:COLRM [Startcol [Endcol]] If there is no endcol then delete all columns from Startcol to the end of the line.

17th Filter: Comparison and extraction

Compare any two files: CMP file1 file2 shows the different bytes and rows.

Compare ordered text files: Comm [ -123] file1 file2 displays three columns: File 1 exclusive, 2 exclusive, common, and parameter-123 to control which columns are not displayed.

Compare unordered text files: diff [-bbiqswy] [-c|-clines|-u|-ulines] file1 file2 Where-I ignores case,-W ignores all whitespace,-B ignores the difference in number of whitespace characters,

-B ignores all blank lines,-Q ignores details (equivalent to CMP), and-C (context) lists the different contexts, the-u (Unified output) uniform outputs, similar to-C but no duplicate rows, and Y-side displays.

The output of diff shows how to modify the first file to a second file, using 3 different single characters: C (change), D (delete), and a (append), a serial number for each character left and right, for readability, and some lines separated by a number of hyphens (---).

It can be thought that paste is similar to cat, paste horizontally combining data, while cat vertically combines data. Paste can also add the-d parameter to specify delimiters, such as paste-d ' |% ' ... will be used in turn | and% delimited data columns.

18th Chapter Filters: Statistics and formatting

Create line number: NL [-v start] [-I increment] [-B A] [-n]

View invisible characters in VI using the command:: Set list, closed with: Set nolist.

Format rows using the fold command: fold [-S] [-w width] [file ...] Where width specifies new line widths,-s tells fold not to split words.

Formatting a paragraph using fmt:fmt [-SU] [-w width] [file ...] where-u reduces whitespace, so that a space between words,-s only splits long lines but does not merge short lines.

Insert one point: The history of the Dvorak keyboard is now a universal QWERTY keyboard, named after 6 letters to the left of the first row of the keyboard. The keyboard was patented by Christopher Sholes in 1868 and later dominated the world. One feature of this keyboard is that the usual letters are deliberately separated, because they are designed to avoid the typebar of the typewriter's linkage.

19th. Filter: Selection, sorting, combination and transformation

Grep:g (Global, represented globally), re (regular expression, regular expression), p (print, printing).

Look selects rows that start with a specific pattern and is faster and can only be read from a file and cannot be read from a standard input. In addition, look can be used to find all words that begin with a solid pattern.

For example, in VI you cannot determine the spelling of a word, you can use: R!look simult, which edits all words beginning with simult to the buffer, selects the correct word, and deletes the rest.

Many programs in Unix use-I (ignore) for ignoring case, but sometimes with-f (fold), fold is a technical term that says lowercase letters are capitalized, and vice versa, whose origins are unknown.

ASCII sort (c or POSIX) and dictionary sort (en_us). Environment variable lc_collate Specifies the sort order (export lc_collate=c or POSIX), using the locale command to view the current value of the locale variable, including the environment variable lc_collate.

Merge the ordered data from two files: join [-i] [-A1|-V1] [-A2|-V2] [-1 field1] [-2 field2] file1 file2

where-A1 output file 1 All,-V (reverse) Only output mismatched, -1 field1 specifies that the first file's Field1 field is the connection field.

Tsort converts a set of partial orders to full order, representing topological sort.

Convert characters with tr: TR [-cds] [Set1 [Set2]] where-s compresses the repeating character into one,-D deletes the specified character, and-C matches all characters that are not in the first group. For example, tr A-Z < old > New and TR [: Upper:] [: Lower:] < old > new equivalent (:d igit: equivalent to 0-9), all uppercase letters in old are converted to lowercase letters and re-lost Out to new.

Unix & Linux University Tutorials (iii): filters,

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.