awk 'BEGIN { clean=1 } /#c3284d#/ { clean=0 } /#/c3284d#/ { clean=1 } { if (clean==1 && match($0,"#/c3284d#") == 0) { print $0 } }' dirty-file > clean-file那是一个大嘴巴,但是可以解决这个问题:
$ cat <<'EOF' | awk 'BEGIN { clean=1 } /#c3284d#/ { clean=0 } /#/c3284d#/ { clean=1 } { if (clean==1 && match($0,"#/c3284d#") == 0) { print $0 } }'> foo> #c3284d#> bar> baz> #/c3284d#> quux> EOFfooquux


