#! /bin/sh # context - dig pattern contexts in text # Copyright (C) 2010 Matous J. Fialka # Released under the terms of The MIT License if [ "$1" = '!' ] then negation='!' shift fi pattern=${@:-'.*'} sed " /^[^ \t]/b process :append H \$ { s/.*/\n/ b process } d :process x /^\$/ b end s/^\n// /$pattern/${negation} p s/.*// :end x /^\n\$/ d b append "