I need help with the shell script I'm trying to execute as follow;
#!/bin/bash
other_oufdir () {
if [[ $(echo "$oufdir"|awk -F"/" '{print $2"/"$3}') != data[1-2]/store ]];then
echo " is not allowed!" && force_oufdir
fi
}
force_oufdir () {
read -r -p "Force output dir? : "
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
:
else
exit 1
fi
}
read -r -p "Enter output dir? : " oufdir
if [[ -z "$oufdir" ]]
then
echo "Cannot be empty!" && echo && exit 1
fi
other_oufdir
if [[ ! -d "$oufdir" ]]
then
mkdir -p -- "$oufdir" && cd "$oufdir"
else
cd "$oufdir" || return
fi
Output is ...
Enter output dir? : /data1/backup/A1
is not allowed!
FORCE output dir? : y
What I want the echo message should be on the same line. Is this possible?
Enter output dir? : /data1/backup/A1 is not allowed!
FORCE output dir? : y