Please use ***[code][/code]
*** tags around your code and data, to preserve the original formatting and to improve readability. Do not
use quote tags, bolding, colors, "start/end" lines, or other creative techniques.
has a useful select
built-in designed specifically for making menus like this:
echo “Main menu”
echo "Select from the following functions"
PS3='Enter a number: '
select answer in "Exit" "Set File Directory" "Text File Management"; do
echo "You chose "answer"
case $REPLY in
1) echo "Exiting the menu"
2) echo "Go up a directory"
echo "Go into a directory"
echo "Set working directory"
3) echo "List (.txt) files”
echo "Create File"
echo "Delete File"
*) echo "Unknown option. Please choose again."
echo "press RETURN for menu"
In addition, I suggest using functions
to modularize the code in the options, particularly if you intend to have sub-menus, as you appear to be doing here. Each menu below the first should have its own function.
As has been explained, Dos/Windows and Unix use different character codes for line endings. If your script or data was created in a Windows-based program, then you'll probably have to convert it before you can use it. A Google search will give you tons of options for doing that.
command is perhaps the easiest way to tell which format it's in. If the output says "with CRLF line terminators", it's a dos-style file. Also "cat -A
" will show you all non-printing characters in caret notation
form. dos files will display a "^M
" at the end of every line.
Finally, also beware that Word changes the regular quotes into "smart quotes". These will not be accepted by the script as syntax elements. Only ' and " can be used.