Note: Always check manually before deleting security groups. There are various places the groups may be used, and the scripts output may not always be conclusive
aws elb describe-load-balancers --query 'LoadBalancerDescriptions[*].SecurityGroups' --output text | tr '\t' '\n' | sort | uniq > used.txt
aws elbv2 describe-load-balancers --query 'LoadBalancers[*].SecurityGroups' --output text | tr '\t' '\n' | sort | uniq >> used.txt