我已经阅读了有关我的问题的更多主题,但没有解决这个问题!
我在my_text文件中有这些文字:
地址dlkjfhadvkahvealkjvhfelkafver
电话4752935729527297
描述fkdshkhglkhrtlghltkg
杂项5897696h8ghgvjhgh578hg
地址klsfghtrgjgjktsrljgsjgm
电话5789058309809583
描述dskjfvhfhgjvnwmrew
其他h09v3n3vt7957jt795783hj
.....
.....
.....
我想用3(或更多)行值过滤此文件数据,例如地址,电话,杂项。
我测试awk '/Address/,/Phone/,/Misc/' my_text
,但错误!
答案 0 :(得分:0)
You need to use or | operator.
Matched line:
awk '/Address|Phone|Misc/{ print $0 }' your_text
Result:
Address dlkjfhadvkahvealkjvhfelkafver
Address dlkjfhadvkahvealkjvhfelkafver
Phone 4752935729527297
Misc 5897696h8ghgvjhgh578hg
Address klsfghtrgjgjktsrljgsjgm
Phone 5789058309809583
Misc h09v3n3vt7957jt795783hj
if you print $1 you get Address, phone or what you matched. And $2 will print your values only.