Skip to content

Instantly share code, notes, and snippets.

@psynaptic
Created April 30, 2012 15:38
Show Gist options
  • Select an option

  • Save psynaptic/2559399 to your computer and use it in GitHub Desktop.

Select an option

Save psynaptic/2559399 to your computer and use it in GitHub Desktop.
count_changes () {
stdin=$(cat /dev/stdin)
lines=$(echo "$stdin" | wc -l)
changes=$(echo "$stdin" | grep "^[+-][^+-]" | wc -l)
removed=$(echo "$stdin" | grep "^-[^-]" | wc -l)
added=$(echo "$stdin" | grep "^+[^+]" | wc -l)
echo total $lines lines. $changes altered: $removed removed, $added added.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment