I have the following function in a script:
createBackupDir()
{
echo "Type the directory name to create"
read NEWDIR
if [[ -a $MILEAGEHOME/$NEWDIR ]]; then
echo "Directory $NEWDIR exists, try again"
else
mkdir $MILEAGEHOME/$NEWDIR
echo "Created directory $NEWDIR"
fi
read key'?Press Enter to continue ...'
}
How can I export the $NEWDIR variable from this function to the rest of the script so that it can be used after the directory is created?
createBackupDir()
{
echo "Type the directory name to create"
read NEWDIR
if [[ -a $MILEAGEHOME/$NEWDIR ]]; then
echo "Directory $NEWDIR exists, try again"
else
mkdir $MILEAGEHOME/$NEWDIR
echo "Created directory $NEWDIR"
fi
read key'?Press Enter to continue ...'
}
How can I export the $NEWDIR variable from this function to the rest of the script so that it can be used after the directory is created?