Skip to content

Instantly share code, notes, and snippets.

@clr
Created November 18, 2014 23:50
Show Gist options
  • Save clr/fcff20b6bdb1496cda28 to your computer and use it in GitHub Desktop.
Save clr/fcff20b6bdb1496cda28 to your computer and use it in GitHub Desktop.
#!/bin/bash
time \
grep --line-buffered < "$1" 'BoxUsage' | \
awk '{FS =","}{print $10,$22}' | \
grep 'BoxUsage' | \
sort | \
uniq | \
awk '{print $1}' | \
sort | \
uniq -c
#!/bin/bash
time \
sed 's/1,0//g;s/0,0//g;s/PUT, COPY, POST,//' < $1 | \
awk '{FS=","}{
if($22)
printf "%s,%s,%s,\"%s%s%s%s%s%s%s%s\"\n", $22, $15, $16, $23, $24, $25, $26, $27, $28, $29, $30}' | \
sort | \
awk '{FS=","}{
if (($1 in arr) && (arr[$1] != "\"\"") && ($4 != "\"\"") && (arr[$1] != $4)) {
printf("%s changed between %s and %s\n tags changed from %s to %s\n", $1, $2, $3, arr[$1], $4)
}
arr[$1] = $4
}'
#!/bin/bash
case "$1" in
application) AWKCMD='{FS=","}{gsub("\"","", $19)}{print $23, $19}';;
cluster) AWKCMD='{FS=","}{gsub("\"","", $19)}{print $24, $19}';;
datatype) AWKCMD='{FS=","}{gsub("\"","", $19)}{print $25, $19}';;
environment) AWKCMD='{FS=","}{gsub("\"","", $19)}{print $26, $19}';;
name) AWKCMD='{FS=","}{gsub("\"","", $19)}{print $27, $19}';;
node) AWKCMD='{FS=","}{gsub("\"","", $19)}{print $28, $19}';;
role) AWKCMD='{FS=","}{gsub("\"","", $19)}{print $29, $19}';;
service) AWKCMD='{FS=","}{gsub("\"","", $19)}{print $30, $19}';;
esac
time \
grep --line-buffered $2 < $3| \
awk "$AWKCMD" | \
grep --line-buffered $2 | \
echo total cost where $1=$2: \$$(awk '{ sum+=$2} END {printf "%.2f\n", sum}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment