The Three Musketeers of Linux

Source: Internet
Author: User

The Three Musketeers of Linux

Awk (the boss of the Three Musketeers) awk/oldboy/test.txt

Filter file command to filter the content file name

Sed (the third swordsman's Dick) Sed-n/oldboy/p test.txt

Filter file-n Cancel default output (parameter) filter file name p for print (display)

grep (Three musketeers of Old three) grep Oldboy test.txt

Main filter command filter content file name


PS: When filtering files, awk and sed need to double slash on both sides of the filter content, grep does not need


# # #实例:

[email protected] data]# cat 2.txt

Abc

Def

Ghi

Jkl

123


Use awk to filter out the "ABC" output in the 2.txt file to redirect to the 1.txt file:

[email protected] data]# Cat | Awk/abc/2.txt > 1.txt


[email protected] data]# cat 1.txt

Abc


Use SED to filter out the "ghi" append output in the 2.txt file to redirect to the 1.txt file:

[email protected] data]# Cat | Sed-n/def/p 2.txt >> 1.txt


[email protected] data]# cat 1.txt

Abc

Def


Use grep to filter out the "def" append output in the 2.txt file to redirect to the 1.txt file:

[email protected] data]# Cat | grep "Ghi" 2.txt >> 1.txt


[email protected] data]# cat 1.txt

Abc

Def

Ghi


This article is from the "13223089" blog, please be sure to keep this source http://13233089.blog.51cto.com/13223089/1962194

The Three Musketeers of Linux

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.