Last active
August 29, 2015 14:01
-
-
Save carymrobbins/e9933077a5d902f9ce18 to your computer and use it in GitHub Desktop.
Limit ack output. Helpful when finding matches in minified files but you don't want to see the entire file in the output.
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
| #!/bin/sh | |
| if [ -z "$1" ]; then | |
| echo "Usage: ack-limit REGEX [OPTIONS]" | |
| exit 1 | |
| fi | |
| REGEX=$1 | |
| shift | |
| ACK=$(which ack || which ack-grep) | |
| $ACK -o ".{0,100}$REGEX.{0,100}" --pager="egrep \"$REGEX|$\" --color=always" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment