#!/usr/bin/env bash # Labs are directly under the root account # There is a documented bug in sacct that will print all accounts whatever the filter # That is, Parent=root only main concequence is that the parent name will only be printed # if it's root and left banck otherwise. labs=$(sacctmgr show account WithAssoc format=Account,ParentName Parent=root -P -n | egrep -v "\|$" | sed -e 's/|root//') for lab in $labs do echo Lab: $lab teams=$(sacctmgr show account WithAssoc format=Account,ParentName Parent=$lab -P -n | egrep -v "\|$" | sed -e "s/|$lab//") for team in $teams do echo Team: $team done done