Skip to content

Instantly share code, notes, and snippets.

@franleplant
Created October 3, 2014 13:42
Show Gist options
  • Save franleplant/7aa081595a9dce348af8 to your computer and use it in GitHub Desktop.
Save franleplant/7aa081595a9dce348af8 to your computer and use it in GitHub Desktop.
{ echo line 1: PASS; echo line 2: FAIL; } |
awk -v "red=$(tput setaf 1)" -v "green=$(tput setaf 2)" \
-v "reset=$(tput sgr0)" '
{ for (i = 1; i <= NF; i++) {
if ($i == "FAIL") printf "%s", red "FAIL" reset;
else if ($i == "PASS") printf "%s", green "PASS" reset;
else printf "%s", $i
if (i == NF) printf "%s", ORS
else printf "%s", OFS
}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment