Skip to content

Instantly share code, notes, and snippets.

@syphoxy
Last active August 29, 2015 13:55
Show Gist options
  • Save syphoxy/8747015 to your computer and use it in GitHub Desktop.
Save syphoxy/8747015 to your computer and use it in GitHub Desktop.
BEGIN {
headerString = ""
footerString = ""
inactiveCount = 0
split("", inactiveTorrents)
activeCount = 0
split("", activeTorrents)
}
$1 == "ID" {
headerString = $0
}
$1 == "Sum:" {
footerString = $0
}
$1 != "ID" && $1 != "Sum:" {
if ($3 != "None" && $9 != "Idle") {
activeTorrents[activeCount++] = $0
}
if ($3 == "None" || ($3 != "None" && $9 == "Idle")) {
inactiveTorrents[inactiveCount++] = $0
}
}
END {
print "Active Torrents:"
print ""
if (activeCount > 0) {
print " "headerString
for (j = 0; j < activeCount; j++) {
print " "activeTorrents[j]
}
# print " "footerString
} else {
print " Nothing to show here."
}
print ""
print "Inactive Torrents:"
print ""
if (inactiveCount > 0) {
print " "headerString
for (j = 0; j < inactiveCount; j++) {
print " "inactiveTorrents[j]
}
# print " "footerString
} else {
print " Nothing to show here."
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment