#! /bin/bash DB=$(grep DB_NAME wp-config.php | cut -d \' -f 4) DBuser=$(grep DB_USER wp-config.php | cut -d \' -f 4) DBpass=$(grep DB_PASSWORD wp-config.php | cut -d \' -f 4) DBhost=$(grep DB_HOST wp-config.php | cut -d \' -f 4) function WPinstallCheck { if [[ ! -f ./wp-config.php ]]; then echo "No WordPress installtion found in this DIR, script must be executed from user's WP directory." 1>&2 exit 1 2> /dev/null fi } function tPrefix { grep -i table_prefix wp-config.php | cut -d \' -f 2 } WPinstallCheck mysql -u $DBuser -p$DBpass -e "use $DB; select option_value from $(tPrefix)options where option_name='active_plugins';" | gawk -v FPAT='[^"]+' -v RS=';' 'NF==2{print $2}' | awk '{print $0}' RS='/'| awk 'NR%2==1'