Sed:获取以“RIM-COD-”开头的行

时间:2012-11-02 20:38:13

标签: bash sed awk

我有文件Blackberry jad文件:

RIM-COD-URL-12: HelloWorld-12.cod
RIM-COD-Size: 68020
RIM-MIDlet-Icon-2-1: ____HOVER_ICON_res/icon/blackberry/icon-68.png,focused
RIM-COD-URL-11: HelloWorld-11.cod
RIM-MIDlet-Icon-Count-2: 1
RIM-COD-URL-10: HelloWorld-10.cod
RIM-MIDlet-Icon-Count-1: 1
MIDlet-Vendor: Vasia Pupkin
RIM-MIDlet-Icon-1-1: res\icon\blackberry\____HOVER_ICON_icon-68.png,focused
Manifest-Version: 1.0
RIM-MIDlet-Flags-1: 0
RIM-COD-SHA1-38: 9a c8 b3 35 72 de 34 5e 7a 0a 5b 9e c3 3a 65 4c 20 0f 8e 50

我只想以RIM-COD-开头。

您能为我提供awksed的解决方案吗?

2 个答案:

答案 0 :(得分:24)

使用sed -n并仅打印与RIM-COD匹配的行。

sed -n -e '/^RIM-COD-/p' yourfile.txt

答案 1 :(得分:22)

尝试这样做:

awk '/^RIM-COD/' file.txt

grep "^RIM-COD" file.txt

或者

sed -n '/^RIM-COD/p' file.txt