Skip to content

Instantly share code, notes, and snippets.

@maxsu
Created July 13, 2012 12:21
Show Gist options
  • Save maxsu/3104619 to your computer and use it in GitHub Desktop.
Save maxsu/3104619 to your computer and use it in GitHub Desktop.
Changelog record finder
# Looks for pattern PATTERN in file input.tex.
# Returns an empty-line delimited block of text surrounding the pattern.
awk
-v "pattern=PATTERN"
-v "bold=$(tput bold)"
-v "sgr0=$(tput sgr0)"
-v RS=
-v 'ORS=\n\n'
'match($0, pattern)
{
o = "";
while (match($0, pattern))
{
o = o substr($0, 1, RSTART - 1) bold substr($0, RSTART, RLENGTH) sgr0;
$0 = substr($0, RSTART + RLENGTH)
}
print o $0
}'
input.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment