Menu with sub-menu options

Hi!
I have created on script which is working fine with menu options and with a sub-menu.
I want to enhance it by using sub-options under menu options.
Like.

option 1) will give the list only.
option 1.1) should give the option to user to choose one file, whose content user wanna see.
I can implement this as a separate option. But I want to implement this under option 1.
Can this be happen? I tried using some but failed.

Here is how my script is working.

#!/usr/bin/ksh

script_menu() {
while :
       do
       clear
echo  some action here
read choice
case $choice in

1) 
some action as per choice;;
2)     
       return;;
3)
       exit;;
    esac 
 done
}

#Main Menu
while :
       do
       clear
       echo ----------------------------------------------------
       echo    ******************Main Menu******************
       echo ----------------------------------------------------
       echo Select a Choice
       echo [1] call sub menu
       echo [2] View Log Files
       echo [3] Exit
       echo ----------------------------------------------------
       echo Select choice {1-2}:
read choice
case $choice in
1)
       script_menu;;
2)     
       echo files; 
       echo Enter file name;
       read -r filename ; find "$filename"_*.* -type f ! -name ".*" 2>errorlog 
       echo Press Enter; 
       read x;;
2.1) Can I solve above question here, like this?

3)   
       exit;;
*) 
       echo Invalid Number
     esac
done

please provide me your valuable help.
Thanks,

correct this and try -

read -r filename ; find $filename"_"*.* -type f ! -name ".*" 2>errorlog 

Hi No problem with that command.
I want to implement separate option for showing the contents of file.
here is the scene:

  1. User enter to view the log files.
  2. Entered the menu number. Menu shows the list of files.
  3. Now he wanna see the contents of a particular file.
  4. There should be an option which make him capable to enter the file name, so that he can see the contents of file.
  5. If he doesn't enter the file name. It should return back to menu. Without saying anything.

Hope I'm able to clear my requirement.

Hiya, I am assuming you are looking to have a sub-menu under an option that will return back to the main menu when exited. This example from another post I replied to shows a way to set up a menu framework using nested select constructs to create the menus. Run it and see if you get some ideas.

$ cat xxx
#!/usr/bin/ksh

#  Set select construct prompts for each menu level.
typeset -r MAINPROMPT="Select a main option: "
typeset -r MANGOPROMPT="Select mango option: "

#  Loop main menu until user exits explicitly.
while :
do
  print "\nTop-level Menu Title Goes Here\n"
  PS3=$MAINPROMPT  # PS3 is the prompt for the select construct.

  select option in "mango (has a sub-menu)" tango rango exit
  do
    case $REPLY in   # REPLY is set by the select construct, and is the number of the selection.
      1) # mango (has a sub-menu)
         #  Loop mango menu until user exits explicitly.
         while :
         do
           print "\nmango sub-menu title\n"
           PS3=$MANGOPROMPT
           select option1 in add substract exit
           do
             case $REPLY in
               1) # add
                  print "\nYou picked [add]"
                  break  #  Breaks out of the select, back to the mango loop.
                  ;;
               2) # subtract
                  print "\nYou picked [subtract]"
                  break  #  Breaks out of the select, back to the mango loop.
                  ;;
               3) # exit
                  break 2  # Breaks out 2 levels, the select loop plus the mango while loop, back to the main loop.
                  ;;
               *) # always allow for the unexpected
                  print "\nUnknown mango operation [${REPLY}]"
                  break
                  ;;
             esac
           done
         done
         break
         ;;
      2) # tango
         ;&  # Fall through to #3
      3) #rango
         print "\nYou picked $option"
         break
         ;;
      4) # exit
         break 2  #  Break out 2 levels, out of the select and the main loop.
         ;;
      *) # Always code for the unexpected.
         print "\nUnknown option [${REPLY}]"
         break
         ;;
    esac
  done
done

exit 0
$