How to cut html tag from very large multiline text file with content with use perl, sed or awk?

后端 未结 4 1866
伪装坚强ぢ
伪装坚强ぢ 2021-01-28 08:10

I want to transform this text (remove .*?) with sed, awk or perl:

{|
|-
| colspan=\"2\"|
: 
[\\underbrace{\\col         


        
4条回答
  •  青春惊慌失措
    2021-01-28 09:01

    This isn't quite the one-liner but it does what you're looking for. As always there are many ways of doing this. But here I am using '|' as the records separator and ':' as the field separator. That allows me to iterate over the fields in a record that contains math and only print the fields that don't contain .

    BEGIN {RS="|";FS=":";ORS=""}
    
    /math/ {
        for (i=1;i<=NF;i++) {
            if ($i ~ /math/) {print ":\n"}
            else {print $i}
        }
        print "|";next;
    }
    
    /^\}/ {
        print "}";
        next;
    }
    
    {
        print $0"|"
    }
    
    END {print "\n"}
    

提交回复
热议问题