Created
December 20, 2015 10:13
-
-
Save chemzqm/55a5246a5b218b9848dc to your computer and use it in GitHub Desktop.
git grep with column and new files
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/bash | |
git --no-pager grep --no-color --no-index --exclude-standard -n $1 | while read git_grep; do | |
file_and_line=$(echo "$git_grep" | cut -d : -f 1,2) | |
match=$(echo "$git_grep" | sed 's/[^:]*:[^:]*:\(.*\)/\1/') | |
column=$(echo "$match" | awk "{print index(\$0, \"$1\")}") | |
echo "$file_and_line:$column:$match" | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment