I need to store the result filename of running gunzip file.gz
into a variable. The only answer I've found is for when the name of the file is known ahead of time. However, in my case, the .gz
file is going to be dynamically generated, so the accepted answer doesn't work.
I tried this:
cd /var/www/backup/db
DB_TAR=$( /usr/bin/ls site_name* -Rt | /usr/bin/head -1 )
DB=$( gunzip ${DB_TAR} )
echo "${DB}"
but got nothing in the output.