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