[SOLVED] Can't get bash case statement to set variable
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
And don't ignore the bash man page - a terrific resource!
Although certainly not tutorial in style, it is actually very readable, accessible and complete - a treasure among man pages!
I think a common obstacle for many is simply its length and unfamiliarity. So learn how it is organized and how to navigate quickly to major topics. Read it, one digestible section at a time to gain comfortable familiarity over time. You will be glad you did!
I'll be checking it out as well. Is that the same information that comes up when I type 'man foo'?
Hm. I do not really think man pages are really useful for beginners, better to use tutorials, read examples and practice, practice and practice. Man pages are usually used to recall forgotten features, options or functionality (and from that point of view they are really usable, a thorough guide to the commands)
Most of the tutorials I've found have been fairly superficial. But that may be because I haven't been searching for the right things. I've used the man pages quite a bit to try and figure things out. But they do tend to be rather vague, even circular in their wording. Still, I'll take any reference I can get. All it takes is to find one option that makes a bit of code work right and then I'm inspired to move forward.
Variable names can start with any letter (upper or lower) or an underscore and then a mix of those plus numbers after that. So I have found in bash it is common to use the underscore as a single character
variable for throw away items. If you were to echo $_ after the read you will get whatever is stored in the position of the last underscore as each one overwrites the next until the last one.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.