alias exclude='_(){ local match="${1}";local lnb="${2}";local lnf="${3}"; (($#<1))||[[ "${1}" =~ ^- ]]&&echo "Usage: exclude <match> [<lines back [0-9],def=0> <lines forward [0-9],def=0>]"&&return 1;awk -vmtch="${match}" -vlnb=${lnb} -vlnf=${lnf} "BEGIN{i=0;skip=0}{if(skip==0 && \$0 ~ mtch){for(j=0;j<lnb&&i>0;j++)delete arr[--i];skip=lnf;}else{if(skip==0)arr[i++]=\$0;else skip--;}}END{for(i=0;i<length(arr);i++)print arr[i];}";};_'
No comments:
Post a Comment