[arch-general] Creation of startup scripts
David C. Rankin
drankinatty at suddenlinkmail.com
Thu Oct 7 18:12:15 EDT 2010
On 10/06/2010 07:59 AM, Jeremiah Dodds wrote:
> man bash, and read the existing init scripts. the stuff in arch is, as far
> as i've seen, clean and well commented. bash scripting has a lot of quirky
> little edge areas though, so it can be hard to ease into. Chapters 7-9 of
> http://rute.2038bug.com/rute.html.gz and the whole of
> http://tldp.org/LDP/abs/html/ helped me out when I was starting to get into
> bash scripting. that was back in 2002 or so, so there may be better
> resources available.
> oh, and don't expect to read all of the bash man page at once. it's huge,
> and filled with all kinds of treasure.
> tinker, and don't be afraid to break things! (you may want to make sure you
> won't be losing anything hugely important before not fearing breakage ... ).
> you'll wake up one day and realize you're the master of your machine, and a
> glorious day it will be.
http://tldp.org/LDP/abs/html with its list of examples is probably the finest
BASH reference available.
In the Advanced BASH Scripting-Guide (abs) you will find examples listed at the
end of each section like this:
10.1.2. Further Reference
For more on string manipulation in scripts, refer to Section 10.2 and the
relevant section of the expr command listing.
1. Example 16-9
2. Example 10-9
** don't skip the examples :p
Additionally, another great resource I found was looking/working through
scripts that did something close to what I needed to do. Especially if they are
well commented. (try to comment your scripts for those that will read them to
learn in the future)
BASH has so many amazing tools and tricks, that it is hard to pick a few of the
favorites. Test constructs, loops and arrays for sure, but probably the most
helpful was taking the time to learn parameter substitution and string
manipulation. (how to get what you need out of a long string of text, string
length, index, etc..) BASH is particularly good at being a swiss-army knife on
strings. You will always be faced with variables that hold a sting that contains
lots of information that you only need 1 part of. The BASH parameter and
sub-string capabilities will save you untold grief if you learn them up front. I
as pages to bookmark, get familiar with, and then go back and learn (I haven't
used the 'expr ..' functions much, but everything else is a must). Also, keep
the quick reference handy:
David C. Rankin, J.D.,P.E.
Rankin Law Firm, PLLC
510 Ochiltree Street
Nacogdoches, Texas 75961
Telephone: (936) 715-9333
Facsimile: (936) 715-9339
More information about the arch-general