Linux Notes--text

Source: Internet
Author: User

Uniq
-I. Ignore case
-C To Count
-fn First N areas are ignored
Wc

Number of characters in a row

-L List only Travel
-W Only how many words are listed
-M How many characters
Cut
-D followed by the split character, used with-f
-F Use-F to go to the first few paragraphs
-C Remove a fixed character range in units of characters
Echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:

echo $PATH | Cut-d ': '-f2

/usr/bin

echo $PATH | Cut-d ': '-f2,5

/usr/bin:/usr/sbin

echo $PATH | Cut-d ': '-f2-5

/usr/bin:/bin:/usr/local/sbin:/usr/sbin

echo $pATH | Cut-c1-4

/usr/lo
Sort
-F Ignore Case differences
-B Ignore the first whitespace part
-M Sort by the name of the month.
-N Use a pure number
-R Reverse Sort
-U Uniq, the same data, only one row is represented
-T Delimiter, which is tab by default
-K Sort by that interval (field) (with-t collocation)
-C Whether the test files have been categorized
-M Merge 2 classification files
-U Delete all replicated rows
-O The file name of the store
For-K, it can also be-k1-k2, which means to sort the second paragraph first, if the same is the second paragraph
Tr
-D Delete character
-S Remove duplicate characters
Cat A.txt | Tr-d ' \ r ' > B.txt
Modify the line break of a DOS file ^m

echo "Hello World" | tr [A-z] [a-z]

HELLO World

echo "Hello World" | Tr-d o

Hell Wrld

echo "Hello World" | TR o A

Hella Warld

echo "Helllllo World" | Tr-s L

Helo World
Tee Dual Guide
-A Adding data to file in a class-plus way
Col
-X Convert tab to peer space key
-B When there is a backslash/in the text, only the last character of the backslash is preserved
Cat-a FILE will appear with many I symbols (tab), you can use the Convert to space function
Join

2 files, the same row that has the same data, is added together.

-T Join by default separates data with spaces, and is more than the data for [first field]
-I. Ignore Case differences
-O Join-o 1.1 2.2 FILE1 FILE2, take only 1 2
-j Join-j1 3-j2 2 FILE1 FILE2, take 3 and 2 parts
-1 Indicates that the first file is to be analyzed with that field.
-2 Indicates that the second file is to be analyzed with that field.
Cat A
111 2222

Cat B

22222 2222

Cat C

111 3333

Join a B

No results

Join-1 2 A-2 2 b

2222 111 3333

Join-1 2 B-2 2 b

2222 3333 111 If the second field of the first file is the same as the second field of the second file, join

Join-1 1 a-2 1 c

111 2222 3333

Join-t ': '/etc/passwd/etc/shadow

Integrate 2 files in the first field into one line

Join-t ': '-1 4/etc/passwd-2 3/etc/group

The fourth field of the first file is compared to the third field in the second file, and the same is combined into a single line. Before using join, the archive should be sorted, or some of the alignment items will be ignored.
Paste
-D followed by the separator character, the default is [tab]
-S Turn a file into a row
Paste/etc/passwd/etc/shadowcat/etc/group | Paste/etc/passwd/etc/shadow-| Head-n 3
Split
-B The file size to be divided into, can be added in unit B K m
-L Split by number of rows


PREFIX represents the preamble meaning and can be used as the leading text for the split file.

Split-b 300k/etc/termcap termcap


ll A.txt

-rw-rw-r--1 Xiang Xiang 3.7K Apr 15:45 a.txt

split-b 2k a.txt a.txt && ls

A.txt  a.txtaa  a.txtab

split-b 2k A.txt a && ll

Total 40k-rw-rw-r--   1 Xiang Xiang 2.0K Apr 15:45 aaa-rw-rw-r--   1 Xiang Xiang 1.7K Apr 15:45 aab
Xargs
-0 If the input stdin has special characters, such as ', \, SPACEBAR, and so on, restore him to a general character
-E EOF can be followed by a string, and when Xargs parses the string, it stops working!
-P When executing the argument of each instruction, the user will be asked;
-N The number of subsequent times, each command instruction executes, uses several parameters.
Find-exec COMMAND {} \;
The action is to execute the previous found as a parameter, and the Xargs will break them down

Find-type F | Xargs file

To view the properties of a file

ls | Xargs Cat | grep "Cmov"

By listing all the files, then cat finds it again with grep.
Expand
-T can be followed by a number, the tab is converted to a space grep ' ^manpath '/etc/man* | Head-n3 | Cat-agrep ' ^manpath '/etc/man* | Head-n 3 | Expand-t 6 | Cat-a

After expand, I was not there because it was converted into a space.

Unexpand Convert a space into tab
grep ' ^manpath '/etc/man_db.conf | Head-n 3| Expand-t 12| Unexpand-t 1 | Cat-a

Linux Notes--text

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.