Created
October 29, 2015 00:19
-
-
Save purplexa/e7a6e90dfae25aafff9c to your computer and use it in GitHub Desktop.
Use grep to print all lines after a match
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 grep_to_end () { | |
| if [ -z $1 -o -z $2 ]; then | |
| echo "Usage:\ngrep_to_end 'regex' file1 [file2 file3 ...]" | |
| exit 2 | |
| fi | |
| for i in $(grep -n -m1 $1 "${@:2}"); do | |
| filename="$(cut -d':' -f1 <<< $i)" | |
| lnum="$(cut -d':' -f2 <<< $i)" | |
| echo "\n--\n$filename:" | |
| tail -n +$lnum $filename | |
| done | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment