Skip to content

Instantly share code, notes, and snippets.

@carymrobbins
Last active August 29, 2015 14:01
Show Gist options
  • Save carymrobbins/e9933077a5d902f9ce18 to your computer and use it in GitHub Desktop.
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.
#!/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