What I want is as follows:
At first when user runs .sh file it displays following:
Review id:
You id is:XXX000YYY
Do you want to change it?[Press Y to change, C to continue]:
Now If user presses Y then let him change id and again show this again, and do this until user presses C to continue. How can I do this in shell script?
I tried following but don't know what to write in if conditions???
while :
do
echo "Enter id:"
read line
echo "Your id: $line"
echo "Do you want to change(Y to change, C to conntinue)?"
read ans
if [ $ans = C ] || [ $ans = c ]; then
/// .... finish the loop
elif [ $ans = y ] || [ $ans = Y ]; then
/// .... continue while loop
else
echo "Wrong selection."
/// .... continue while loop
fi
exit 0
I changed it to following, but now it's in infinite loop:
echo "Enter id:"
read line
echo "Your id: $line"
echo "Do you want to change(Y to change, C to conntinue)?"
read ans
while [ $ans = y ] || [ $ans = Y ];:
do
echo "Enter id:"
read line
echo "Your id: $line"
echo "Do you want to change(Y to change, C to conntinue)?"
read ans
done

ifpart? – mark Feb 9 at 4:57