Linux 13th Day Text Operations Command

Source: Internet
Author: User
Tags diff

Linux 13th Day

Time: 20180730


Text Manipulation Command Learning


/dev/urandom a device that generates random characters

Cat/dev/urandom |TR-DC ' [: alnum:][:p rint:] ' |head-c10 output a random string

Do password use


Paste outputs the contents of two documents to standard output according to line number alignment

-d Specifies the middle separator in the alignment output of two documents, the default is tab

-S merges each document into a single line and then merges two documents together into two lines of content

The line number character of the WC statistic document, etc.

-L Output Document line number

-W Output Document Word Count

-c Number of bytes in the output document

-m number of characters in the output document

Netstat output network connection, routing table, interface status information, etc.

Sort the lines of a document

-t specifies the field separator to sort

-k Specifies the first field to sort

-N Sort by number size

-R Reverse Reverse sort

-U to repeat, remove duplicate rows

-R Random Sort

Uniq output or ignore duplicate rows

-C output Number of duplicate rows

-U outputs non-repeating rows only

-D output Duplicate rows only

Diff output two files in a different place

Diff-u file1 file2

-U outputs the difference of two content and shows how to modify each of its files to be the same as the other one

Patches can be used to restore another file through one of the different diff pairs.

Patch-b Orifile Difffile

-B backup File

Grep

-V reverses the row to which it is matched

-I ignores character case when matching

-N Displays the line number of the line to which it is matched

-C Displays the number of rows that are matched to

-O only displays the text matched to

-Q silent mode, which indicates that only the lookup matches to, using echo $? Can query whether matches to, used to do detection use

-A output matches the row plus the contents of the following n rows

-B output matches the row plus the contents of the first n rows

-C output matches rows and lines of content

-e implementation matches multiple pattern, between yes or relationship

-W indicates that a word is matched, that is, a word that consists of a non-underscore, and a number in the middle

-e using extended regular expressions

-F uses Fgrep to not use regular expressions, directly matches their strings, fast


Basic Regular Expressions

Character matching

. Match any single character

[] matches any single character specified in the brackets

[^] matches any single character specified in brackets

[: Alnum:] [:d Igit:] [: Upper:] [: Lower:]

[:p UNCT:] [: Alpha:] [: Space:] [: Blank:] Spaces and tabs

[:p rint:] printable character [: Cntrl:]


Number of Matches

\? Match Front character 0 or 1 times

* matches the preceding character any time, including 0 times

. * denotes any character any time

\{n\} matches the preceding character n times

\{n,\} matches the preceding character at least n times

\{n,m\} matches the preceding character at least n times, up to M times

\{,m\} matches the preceding character within m times, including 0 times

\+ match front character at least once


Position anchoring

\< or \b matches the first word, that is, the word is separated by a non-underscore, or a number, a letter.

\> or \b Match ending

\<word\> Match Whole Word

^ Match beginning of Line

$ Match Line End

^$ Matching Blank lines

^[[:space:]]*$ matching blank lines with spaces


Group

Combine a pattern or multiple matches into a single whole for a back reference

A back reference is a character that references a pattern in the parentheses in front, not the pattern itself

\ (pattern\)



Extending regular Expressions

Character matching (with the basic regular match yes there are backslashes removed)

. Any single character

[] Specify any single character in the range

[^] Any single character outside the specified range


Number of Matches

* Any number of characters ahead

? Front character 0 or 1 times

{n} exactly matches the preceding character n times

{N,} matches the preceding character at least n times

{n,m} matches the preceding character at least n times, up to M times

{, m} matches the forward character up to M times


Position anchoring

^ Beginning of the line

$ End of line

< word head

> Endings


Group

()

Back To reference \1,\2 ...




Nmap network detection and port detection tools

The line number of the NL output document (the line number of the line with the text is output only)

Last output user who recently logged on to this machine

LASTB output the user who recently logged on to this machine was unsuccessful


Linux 13th Day Text Operations Command

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.