I was trying the below code to retrieve database name from wordpress configuration file. But somehow a single inverted comma at the beginning is causing trouble.
db=`grep DB_NAME /var/www/vhosts/domain.com/httpdocs/wp-config.php | tr -d "(',);" | cut -d" " -f2`; echo $db; mysqldump -uadmin -p$(cat > /etc/psa.psa.shadow) $db > $db.sql
As given below it shows the output without any special characters but the below error shows an issue.
laysalaysa_laysalaysa '" when selecting the databasencorrect database name 'laysalaysa_laysalaysa'
Advertisement
Answer
carriage return (r) caused the issue. Truncated it and script worked. But could not identify what cause the same.