Skip to content

Instantly share code, notes, and snippets.

@colstrom
Last active December 9, 2016 06:53
Show Gist options
  • Select an option

  • Save colstrom/9cf760272426d95e409a740f7a4f5f11 to your computer and use it in GitHub Desktop.

Select an option

Save colstrom/9cf760272426d95e409a740f7a4f5f11 to your computer and use it in GitHub Desktop.
lines-after.fish: prints lines after a given pattern
name = lines-after
author = Chris Olstrom
license = MIT
provides = fish/functions/lines-after
requires
command/awk
fish/builtin/case
fish/builtin/count
fish/builtin/echo
fish/builtin/end
fish/builtin/function
fish/builtin/return
fish/builtin/switch
function lines-after --argument pattern
switch (count $argv)
case 0
echo 'usage: lines-after <pattern>'
return 100
case '*'
awk "/$pattern/ { matched=NR; next } matched"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment