Very important basic Commands Three Musketeers plus find

Source: Internet
Author: User

Find-type: Search by file type

-name: Search by file name

! Take counter

SED command combat:

Sed-n "2p" oldboy.txt print the second line

Sed-n "1,2p" Oldboy.txt print line first to second

Replace DDD with Oldboy print: sed ' s#ddd#oldboy#g ' oldboy.txt

Change the content ddd to Oldboy and print: Sed-i ' s#ddd#oldboy#g ' oldboy.txt

Basic Regular Expressions: Some special symbols represent some special functions and functional definitions.

Sed-i ' s# (regular match available) #\1#g ' Oldboy.txt

. Single arbitrary character

* Repeat any of the preceding 0 or more characters

. * matches any character

Enclose the result in parentheses in the preceding regular match, followed by a \1 representation.

$ A indicates the entire row

Example: Sed-r ' s# (. *) Fff#\1#g ' oldboy.txt matches the characters in front of FFF and outputs

Sed-r ' s# (. *) (. *) #\1 \2#g ' oldboy.txt matches characters before and after spaces and outputs

awk Command Combat:

awk ' {print '} ' Oldboy.txt takes the first column

awk ' {print $ oldboy.txt} ' takes first, two columns

awk ' {print $NF} ' Oldboy.txt takes the last column

Awk-f "Specify delimiter" ' {print $NF} ' Oldboy.txt

Cat-n Display the line number of the file

awk ' {nr>20&&nr<26} print $/etc/passwd prints 21-25 lines

grep command Combat:

grep***** (good at filters) separate the desired or unwanted (the default whole line)

-V Exclusion

-I is case insensitive

-E Filter Multiple strings

-O outputs precisely matched characters without

-N Line number

Linux Three Musketeers old three

-B In addition to displaying a matching row, and displaying the NUM lines before the line

-a displays a matching row and Num lines after that line

-c Displays the NUM row before and after the line, except for a matching row

grep "string"-B 1.txt

--color=auto to match the string to a color

grep 3306/etc/services

grep--color=auto 3306/etc/services

Very important basic Commands Three Musketeers plus find

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.