LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Can't get bash case statement to set variable (https://www.linuxquestions.org/questions/programming-9/cant-get-bash-case-statement-to-set-variable-4175596761/)

Southern Gorilla 01-05-2017 02:42 AM

Quote:

Originally Posted by astrogeek (Post 5650588)
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'?

pan64 01-05-2017 02:45 AM

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)

Southern Gorilla 01-05-2017 02:52 AM

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.

grail 01-05-2017 06:47 AM

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.

Southern Gorilla 01-05-2017 06:56 AM

Now that is an awesome trick.

I've learned more in this one thread than I learned from the book I got a week ago.


All times are GMT -5. The time now is 10:29 PM.