Skip to content

Instantly share code, notes, and snippets.

@altbdoor
Created August 12, 2016 06:16
Show Gist options
  • Save altbdoor/a68c8acf4ea817dfb54047881e98f83b to your computer and use it in GitHub Desktop.
Save altbdoor/a68c8acf4ea817dfb54047881e98f83b to your computer and use it in GitHub Desktop.
#!/bin/bash
filename="$1"
parameter="$2"
if [[ ! -f "$filename" ]]; then
echo "Please specify the file"
exit 1
fi
if [[ -z "$parameter" ]]; then
echo "Please specify the xml attribute"
exit 1
fi
grep -oE "$parameter=\"[0-9]+\.[0-9]+\"" "$filename" | sed -e "s/^$parameter=\"//" -e "s/\"$//" | awk '{sum+=$1} END{print sum;}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment