Created
May 25, 2016 23:47
-
-
Save inodb/693d4db1c52398734987e350d91d2c5d to your computer and use it in GitHub Desktop.
Use grep --color=always to color a file by another file of patterns. Pretty useful for sequencing analysis
This file contains 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
color_grep_file() { | |
COLOR_CMD="cat $1" | |
echo $COLOR_CMD | |
local i=31; | |
while read line; do | |
echo $line | |
COLOR_CMD="$COLOR_CMD | GREP_COLOR='01;$i' grep --color=always -E '$line|$'" | |
i=$(( $i + 1 )) | |
done < $2 | |
COLOR_CMD="$COLOR_CMD | less -RS" | |
bash -c "$COLOR_CMD" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: