I'm looking for some common problems in unix system administration and ways that shell scripting can solve them. Completely for self-educational purposes. Also I'd like to know how would you go about learning shell scripting.
Any time you EVER find yourself doing something multiple times, script it. Think as lazy as you possibly can. Computers were built to do all of that menial crap. Any thing that smells like busy work needs a shell script.
Personally, I learned by rummaging around in Slackware for a couple of years. See what happens when you strip your system back as much as possible. Learn to be comfortable with text. While everybody else is ooing and awing over NetworkManager, learn how simple it is to make your own damn NetworkManager. Sure, it might not have as many use cases, but you can get something up and running, dynamically connecting via ethernet and wireless on-demand pretty simply enough.
I would like to re-recommend the three books that I suggested in another thread, these are in my opinion the best books to get into the spirit of Unix:
- The Unix Programming Environment from Kernighan and Pike
- Unix for the Impatient
- O'Reilly's Unix Power Tools.
The first one is old, very old, but it is concise, a short read and will give you the shell chops that you need (regular expressions, sed, pipelines).
The second one is incredibly entertaining.
The third one is a collection of "best of" tricks from the Unix masters in the 90's (That is when I read it). The book keeps getting re-edited, so I am sure it contains many new nuggets.
There is a wealth of great information in the Advanced Bash-Scripting Guide, and it's frequently updated to stay current.
I second Miguel's recommendation of 'The Unix Programming Environment'. Its really old but its how I learned almost everything I know about the shell and because its so old you can get it for just a few bucks on amazon: http://is.gd/eiSn6
Find a book or a manual and treat your chosen shell like a programming language, because it is. (Well, maybe not csh...)
For starters, learn how to figure out if you're in a Bash shell, Bourne shell, csh, zsh, or whatever. Some of these are similar to eachother like C and C++ -- deceptively different -- so knowing which one you're fighting with will help you find examples and manuals that actually will help in a given situation.