#!/bin/bash # +----+----+----+----+ # | | | | | # Author: Mark David Scott Cunningham | M | D | S | C | # +----+----+----+----+ # Created: 2017-02-14 # Updated: 2017-02-14 # # Purpose: Find dbusers mapped to the wrong account # for x in $(find /var/cpanel/databases -type f -not -group root -name '*.json'); do username=$(basename $x .json); for dbuser in $(sed 's/\"/\n/g' $x | grep _ | sort | uniq); do if [[ ! $dbuser =~ ${username}_ ]]; then echo -e "\n$dbuser :: $x\n"; read -p "... pausing ..." pause; vim $x; fi; done; done