Nice solution!
Here's another way to do it with minimal modification of your existing code! I like to use functions, especially if what I'm working with is part of a larger script. In this case, you might be able to put your menu prompt bit into a function, and have it call the function again if the user answers "n"
(Lines I've added are marked with "##")
Code:
#!/bin/bash
## Let's enclose the menu prompt in a function!
PROMPT () { ##This line begins the function
cat << MENU
Select which NIC to configure:
1 - eth0
2 - eth1
MENU
read NIC
} ## This bracket closes the function
## Here's where we run the function the first time
PROMPT
## Now we do a loop, similar to Keith's while loop
until [ "$answer" = "y" ]; do
case "$NIC" in
"1" )
echo -e "Are you sure you want to configure eth0? (y/n)? \c "
read answer
if [ "$answer" = y ] ; then
echo "Fill in the following questions:"
#blah blah blah...I'll grab their responses and input them accordingly into ifcfg-eth0
else
echo "Let's start over."
#this is where I need to redirect it back to the first question
PROMPT ## This displays the menu again
fi
;;
"2" )
echo -e "Are you sure you want to configure eth1? (y/n)? \c "
read answer
if [ "$answer" = y ] ; then
echo "Fill in the following questions:"
#blah blah blah...I'll grab their responses and input them accordingly into ifcfg-eth1
else
echo "Let's start over."
#this is where I need to redirect it back to the first question
PROMPT ## This displays the menu again
fi
;;
esac
done ## This ends the 'until' loop
exit
Depending on the version of bash you're using, it might like the function to start with the word "function", but this works in my shell, and seems to be the closest to a "drop-in" solution for your existing script.
There are more ways to streamline this script too! For instance, your verification y/n code could be put into a function, so that you don't have essentially the same 'if' statement in there twice.
Also, you can replace these two lines:
Code:
echo -e "Are you sure you want to configure eth1? (y/n)? \c"
read answer
...with this ONE line:
Code:
read -p "Are you sure you want to configure eth${NIC}? (y/n)? " answer
I hope this helps!
( Sorry for the unsolicited extra bits :$ )