Reputation: 93
How to view records, which does not have particular fields... to begin with, my input need particular Record and field separator
BEGIN {
RS="";
FS="\n";
}
and here is my input:
<Row>
<Cell><Data ss:Type="String">Networks menu (disabled)</Data></Cell>
<Cell><Data ss:Type="String">Networks</Data></Cell>
<Cell ss:Index="4"><Data ss:Type="String">Select</Data></Cell>
<Cell><Data ss:Type="Boolean">0</Data></Cell>
<Cell><Data ss:Type="String">Back</Data></Cell>
<Cell ss:Index="8"><Data ss:Type="String" x:Ticked="1">1</Data></Cell>
<Cell><Data ss:Type="String">"Networks Sel","GPRC Mode"</Data></Cell>
<Cell ss:StyleID="s73"/>
<Cell ss:StyleID="s73"/>
<Cell ss:StyleID="s73"/>
</Row>
<Row>
<Cell ss:StyleID="s93"><Data ss:Type="String">New Code?</Data></Cell>
<Cell ss:StyleID="s62"/>
<Cell ss:StyleID="s62"/>
<Cell ss:StyleID="s62"/>
<Cell ss:StyleID="s62"><Data ss:Type="Boolean">0</Data></Cell>
<Cell ss:StyleID="s62"><Data ss:Type="String">Cancel</Data></Cell>
<Cell ss:StyleID="s62"><Data ss:Type="Boolean">0</Data></Cell>
<Cell ss:StyleID="s62"><Data ss:Type="String" x:Ticked="1">-1</Data></Cell>
<Cell ss:StyleID="s62"><Data ss:Type="String">"?|New Code?"</Data></Cell>
<Cell ss:StyleID="s95"/>
<Cell ss:StyleID="s95"/>
<Cell ss:StyleID="s95"/>
</Row>
<Row>
<Cell ss:StyleID="s156"><Data ss:Type="String">New Message Arrived</Data></Cell>
<Cell ss:Index="3"><Data ss:Type="String">ANIMATION_REC_MAIL</Data></Cell>
<Cell><Data ss:Type="String">Read</Data></Cell>
<Cell><Data ss:Type="Boolean">0</Data></Cell>
<Cell><Data ss:Type="String">Back</Data></Cell>
<Cell><Data ss:Type="Boolean">0</Data></Cell>
<Cell ss:StyleID="s117"><Data ss:Type="String">-1</Data></Cell>
<Cell><Data ss:Type="String">NOT EXIST </Data></Cell>
<Cell ss:StyleID="s73"/>
<Cell ss:StyleID="s73"/>
<Cell ss:StyleID="s73"/>
</Row>
How to view all input, exept ONE record, which second field is "New Code?" (here will be some regular expression)
Upvotes: 0
Views: 416
Reputation: 247012
If you want to keep the blank line between records, you also need to set the ORS
variable. You want to use awk's matching operator ~
on the second field.
awk '
BEGIN {RS=""; FS="\n"; ORS="\n\n"}
$2 ~ /New Code\?/ {next}
{print}
'
As @EdMorton mentions, this can be written more concisely:
awk 'BEGIN {RS=""; FS="\n"; ORS="\n\n"} $2 !~ /New Code\?/'
Upvotes: 3