Last active
December 9, 2016 06:52
-
-
Save colstrom/80b844c38babdd03f32fae27bff41ce5 to your computer and use it in GitHub Desktop.
lines-before.fish: prints lines that occur before a given pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name = lines-before | |
| author = Chris Olstrom | |
| license = MIT | |
| provides = fish/functions/lines-before | |
| requires | |
| command/awk | |
| fish/builtin/case | |
| fish/builtin/count | |
| fish/builtin/echo | |
| fish/builtin/end | |
| fish/builtin/function | |
| fish/builtin/return | |
| fish/builtin/switch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function lines-before --argument pattern | |
| switch (count $argv) | |
| case 0 | |
| echo 'usage: lines-before <pattern>' | |
| return 100 | |
| case '*' | |
| awk "/$pattern/ { exit }; 1" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment