|
Softpanorama |
May the source be with you, but remember the KISS principle ;-)
Softpanorama Search
|
| Unix Tools | Sysadmin | ||||||
| ksh88 and posix shell | Bourne Shell | Bash | Perl | Etc |
Unix shells are far from being simple and are very important members of scripting language family. Very underestimated members of the scripting language family I would say. Actually Unix shells Born shell and C-shell can be considered as fathers of a modern scripting languages. Among descendants are ksh93 and zsh which is some respects (operations with pipes is one example) are more modern and powerful then Perl.
There are very few good shell books. Among introductory I would say that one of the few that is worth the money is Unix Shell Programming, Third Edition by Stephen Kochan, Patrick Wood. This is a really unique, very well thought out presentation of Borne shell. Another very good book is Learning the Korn Shell (2nd Edition) Actually I prefer the first edition. Similar structured book for BASH is Learning the bash Shell . Both should probably be used with Bash Cookbook: Solutions and Examples for bash Users as while presentation is good, they lack good, practical examples, the examples which can be found in Bash Cookbook
Many introductory shell books that try cover both ksh and C shell end with covering none well. One exception (for Solaris users only) is probably A Practical Guide to Solaris which has rather weak coverage of three shells (and that's a rather strange idea to cover all three in the intro book) but as a compensation contains a good reference that covers grep, sed and awk -- very useful utilities for shell scripting. That is the book that I used in my university courses and currently (with certain reservations, see review below) I would recommend it as a first book, especially for a university course based on Open Solaris.
For an intermediate book I recommend to buy a book that specifically covers shell that you is/will be using be it bash, ksh93 or whatever. If you are using Solaris then on the intermediate and advance levels I would recommend you to pay a special attention to ksh93 -- one of the most modern (and now free) Unix shells. ksh93 is more powerful that ksh88(or POSIX shell) and is better programming shell then bash (bash is better interactive shell, though). Unfortunately only very few published books cover the most interesting features that are present in ksh93 (especially co-routines and co-processors). In this respect nothing can replace the author view on the language as in The New Kornshell : Command and Programming Language.
That's does not mean that you should start learning shell with this book, though ;-). I think Learning the Korn Shell (1nd Edition) is a better intermediate book, probably the best for those who already have some exposure to Unix (the second edition is OK too, but I like the first edition better). BTW ksh93 source code was released on March 1, 2000. For more details see the comp.os.unix.shell FAQ posting on shell comparisons. Bash 2.0 is weaker that ksh93 as a scripting language but is better interactive shell. Bash 3.0 has a built-in debugger which is a nice thing and an improvement in a right direction, but right now it's too early to judge how good it is.
Please note that Learning the Korn Shell is a higher level book than A Practical Guide to Solaris and is not suitable for those that has no exposure to Unix and take Intro to shell programming as the first Unix course. But of course if you want to learn shell programming, not just writing a dozen of line scripts it's a much better book.
Dr. Nikolai Bezroukov
by Randal K. Michael (Author)
From foreword:
We urge everyone to study this entire book. Every chapter hits a different topic
using a different approach. The book is written this way to emphasize that there is
never only one technique to solve a challenge in UNIX. All the shell scripts in this book
are real-world examples of how to solve a problem. Thumb through the chapters, and
you can see that we tried to hit most of the common (and some uncommon!) tasks
in UNIX. All the shell scripts have a good explanation of the thinking process, and
we always start out with the correct command syntax for the shell script targeting a
specific goal. I hope you enjoy this book as much as I enjoyed writing it. Let’s get
started!
A must-have for all levels of *nix users. ,
August 1, 2004
By Bindlestiff (rixtertech.com) - See all my reviews
This review is from: Mastering UNIX Shell Scripting (Paperback)The breadth of real-world examples make the difference between this book and most reference texts. It's true that it's written for korn, but I've had little trouble adapting for Bash; many of the scripts run almost unchanged and the ones that don't provide a useful opportunity for exercise in adaptation. The authors prose is clear. His attitude is a bit challenging; he says early on that that his intention is to teach you how to -solve problems- by shell scripting, NOT to present a ream of canned solutions. This is NOT a reference text for any particular shell, you'll still need plenty of O'Reilly books, a web browser & etc.
This book has enabled me to write a major project using scripting as the glue to hold together a hefty mass of file-moving daemons, fax/paging engines, python UI code, PostGreSQL database engine, networking/email, SSH, and Expect scripts on a Gnu Linux platform. I absolutely could not have done it without this book and I'm very grateful to Mr Michael for his work. If a later edition could more closely serve the needs of the masses by presenting more Bash examples and maybe throwing in a CD it would be a 5-star text.
Quote
#, precedes each line of a comment.Command readability and step-by-step comments are just the very basics of a
well-written script. Using a lot of comments will make our life much easier when we
have to come back to the code after not looking at it for six months, and believe me; we
will look at the code again. Comment everything! This includes, but is not limited to,
describing what our variables and files are used for, describing what loops are doing,
describing each test, maybe including expected results and how we are manipulating
the data and the many data fields. A hash mark,
The
script stub that follows is on this book’s companion web site at www.wiley.com/go/michael2e
. The name is script.stub. It has all the comments ready to get startedwriting a shell script. The
script.stub file can be copied to a new filename. Edit thenew filename, and start writing code. The
script.stub file is shown in Listing 1-1.#!/bin/Bash
#
# SCRIPT:
NAME_of_SCRIPT# AUTHOR:
AUTHORS_NAME# DATE:
DATE_of_CREATION# REV:
1.1.A (Valid are A, B, D, T and P)#
(For Alpha, Beta, Dev, Test and Production)#
# PLATFORM: (SPECIFY: AIX, HP-UX, Linux, OpenBSD, Solaris
# or Not platform dependent)
#
# PURPOSE: Give a clear, and if necessary, long, description of the
# purpose of the shell script. This will also help you stay
# focused on the task at hand.
#
# REV LIST:
# DATE:
DATE_of_REVISION# BY:
AUTHOR_of_MODIFICATION# MODIFICATION:
Describe what was modified, new features, etc--#
#
# set -n # Uncomment to check script syntax, without execution.
# # NOTE: Do not forget to put the comment back in or
# # the shell script will not execute!
# set -x # Uncomment to debug this shell script
#
##########################################################
# DEFINE FILES AND VARIABLES HERE
##########################################################
Listing 1-1
script.stub shell script starter listingMichael c01.tex V4 - 03/24/2008 4:45pm Page 8
8 PartI■ The Basics of Shell Scripting
##########################################################
# DEFINE FUNCTIONS HERE
##########################################################
##########################################################
# BEGINNING OF MAIN
##########################################################
# End of script
Listing 1-1
(continued)The shell script starter shown in Listing 1-1 gives you the framework to start writing
the shell script with sections to declare variables and files, create functions, and write
the final section,
BEGINNING OF MAIN, where the main body of the shell script iswritten.
Solutions to problems for bash users of all skill levels,
June 25, 2007
By calvinnme "Texan refugee" (Fredericksburg, Va) - See all my reviews
This book covers the GNU Bourne Again Shell, which is a member of the Bourne family of shells that includes the original Bourne shell sh, the Korn shell ksh, and the Public Domain Korn Shell pdksh. This book is for anyone who uses a Unix or Linux system, as well as system administrators who may use several systems on any given day. Thus, there are solutions and useful sections for all levels of users including newcomers. This book is full of recipes for creating scripts and interacting with the shell that will allow you to greatly increase your productivity.
- Chapter 1, "Beginning bash" covers what a shell is, why you should care about it, and then the basics of bash including how you get it on your system.
- The next five chapters are on the basics that you would need when working with any shell - standard I/O, command execution, shell variables, and shell logic and arithmetic. Next there are two chapters on "Intermediate Shell Tools". These chapters' recipes use some utilities that are not part of the shell, but which are so useful that it is hard to imagine using the shell without them, such as "sort" and "grep", for example.
- Chapter 9 features recipes that allow you to find files by case, date, type, size, etc.
- Chapter 10, "Additional Features for Scripting" has much to do with code reuse, which is something you find even in scripting.
- Chapter 11, "Working with Dates and Times", seems like it would be very simple, but it's not. This chapter helps you get through the complexities of dealing with different formats for displaying the time and date and converting between various date formats.
Chapter 12, "End-User Tasks As Shell Scripts", shows you a few larger though not large examples of scripts. They are meant to give you useful, real world examples of actual uses of shell scripts beyond just system administration tasks.
- Chapter 13, "Parsing and Similar Tasks", is about tasks that will be familiar to programmers. It's not necessarily full of more advanced scripts than the other recipes in the book, but if you are not a programmer, these tasks might seem obscure or irrelevant to your use of bash. Topics covered include parsing HTML, setting up a database with MySQL, and both trimming and compressing whitespace.
- Chapter 14 is on dealing with the security of your shell scripts.
- Chapters 15 through 19 finish up the book starting with a chapter on advanced scripting that focuses on script portability.
- Chapter 16 is related to the previous chapter on portability and is concerned with configuring and customizing your bash environment.
- Chapter 17 is about miscellaneous items that didn't fit well into any other chapter. The subjects include capturing file metadata for recovery, sharing and logging sessions, and unzipping many ZIP files at once.
- Chapter 18 deals with shortcuts aimed at the limiting factor of many uses of bash - the typing speed of the user and shortcuts that cut down on the amount of typing necessary. The final chapter in the book, "Tips and Traps", deals with the common mistakes that bash users make.
All in all this is a very handy reference for a vast number of the tasks that you'll come across when scripting with the bash shell along with well-commented code. Highly recommended.
Good chapter on debugging.,
November 16, 2006 Good chapter on debugging. Good overview of the Bash shell, but I wish it had more examples. For a book with lots of examples, you might want to consider "Bash Shell: Essential Programs for Your Survival at Work" by Larry L. Smith.
by Arnold Robbins, Nelson H.F. Beebe
This might be a great second book on shell scripting. Can serve as a valuable add on to "Learning Korn shell" from O'Reilly -- also a very strong book on shell scripting.
The authors provide a lot of interesting and useful information that is difficult to find in other books. They devoted Ch 5 to piping and in 5.4 "Word List" they discuss famous Doug McIlroy alternative solution to Donald Knuth program of creating the list of the n most-frequent words, with counts of their frequency of occurrence, sorted by descending count from an arbitrary text file.
The authors discuss many Unix tools that are used with shell (Unix toolbox). They provide a very good (but too brief) discussion of grep and find. Discussion of xargs (which is usually a sign on a good book on scripting) includes /dev/null trick, but unfortunately they do not mention an option -0n with which this trick makes the most sense.
One of the best chapters of the book is Ch. 13 devoted to process control. Also good is Chapter 11 that provides a solution to pretty complex and practically important for many system administrators task of merging passwd files in Unix. It provides a perfect insight into solving real sysadmins problems using AWK and shell.
Shortcomings are few. in "5.2. Structured Data for the Web" the authors should probably list AWK instead of SED. Also XML processing generally requires using a lexical analyzer, not regular expressions. Therefore a tag list example would be better converted to something simpler, for example generating C-tags for vi.
Looks very promising. Very well thought out organization which is evident event from the table of content: better that in any other book that I know. As the first edition there are too many errors but for a professional reader that does not matter much, which matter are concepts and due to this this book is uniquely useful. Unfortunately not all errors are just typos, some errors are conceptual, for example when discussing XRAG the author fails to mention the option 0n that prevents overflowing of the argument list (in this case commands are executed one by one).
Publisher URL: http://www.awl.com/cseng/
See also LJ 74 Book Review
this book has many examples other don't have!, October 22, 2000
Reviewer: A reader
1. This book contains many errors like other readers have pointed out, but its shell programming examples really help me. Those examples I can't find from other books.2. This book will not help you too much in unix concepts, and thus you may have to buy another good unix concepts book to solve those problems.
3. overall, as long as you have enough time to play those examples in your unix machine and want to write a 30 pages of codes like those in chapter 21 and 22, this is definitely the one you want and bring you to another level!
4. personally, I buy two different books to study a computer skill. One is the text book by college professor who may insure the concepts are correct, the other is the book having enterprise examples. But it is so hard for one to find the one having both. This book partially fit my second need!
Tansley's Linux book is an Amazing Friend to keep nearby, March 28, 2000
Reviewer: John (GodLovesEveryone.org) (Northwest Arkansas) - See all my reviews A friend of mine raves about "Linux & Unix Shell Programming" by David Tansley, and I certainly have to agree with him.
In my case, I had to add Linux to my Windows 98 computer so that I could better talk to and understand programmers who enter the programming contest at <www.MSOworld.com/programming.html>. This book would almost be my "Best Friend" if such a thing were possible, because it lets me look up the DOS terms I memorized years ago and see the equivalent Linux terms and syntax. (I'm in love with that feature, by the way).
"Linux & Unix Shell Programming" even has material that will help you learn the same CGI that is found on many web pages, and, thank goodness, the wild cards I fell in love with in DOS are there.
As you can see from the table of contents, below, it covers quite alot of ground, from "Introduction to Linux/Unix in general" to "Building CGI scripts for a web site."
Cool, eh?
Definitely buy it if you're looking to understand Linux, and especially if you're an old DOS user from the early computer age.
The Table of Contents is below. I hope you fall in love with it.
John Knoderer
mazes@msoworld.com
webmaster@mazes.com
Best Shell Programming Book I've Found Yet!, July 6, 2004
Reviewer: Gregory D. Donovan (Golden, CO) - See all my reviews I own no less than ten books on shell programming and this one has helped me more than the rest combined.
The author has the talent for condescending to my level to explain concepts that I have had a great deal of trouble understanding.
I was able to write a menu driven script to simplify the loading and unloading of a tape library after reading just two chapters from the middle of the book.
I even created my first shell function in the process. Yes there are a few typos. I'm not sure why some of the more sophisticated reviewers had a problem with this.
I still found the book very useful and was able to catch the intended meaning in spite of the typos. If you are a genius this book may not be for you. If you are trying to learn how to write scripts quickly I highly recommend it.
I would have traded all my other scripting books for this one had I known how useful it is.
Reviewer: Victor Kamat (Modesto, CA United States) - See all my reviews Reviewer: A reader from Modesto, CA United States
This is a marvellous book on Unix/Linux shell programming. D. Tansley knows unix/linux very well, and is a very good teacher too. (In my opinion if you study this book and "The Korn Shell" by Olczak you'll become very good at Unix and Shell scripting.)He has obviously thought a great deal about the organization of the book; in my opinion he has done it very well.
About 1/2 the book is devoted to grep, find. awk, cron, file permissions, quoting, the login environment, etc. His explanations are the best I have read, and all this is enhanced by his organization of the material and his examples.
He then gets into shell scripts, things like conditional testing, control flow structures, functions, and then more advanced material. And once again he does a very nice job.
The more I read this book and use it in my daily work, the more impressed I am with it. If you are a unix/linux user do yourself a favor and get this book.
One reviewer has given this book a scathing review; in my opinion this reviewer is totally off-the-wall. It may be that he has a problem with the english language (he's from Swizterland). Set aside his remarks.
by Stephen Kochan, Patrick Wood
|
|
by Ken O Burtch
Price: $24.49
This is an average or below average book on bash. But like in many books of Linux wanna-bees errors are rampant and understanding of shell is lacking. Here is one glaring example of both author oversight and editor neglect ( page 22):
"The tilde (~) represents you current directory.
.... Although .. and .. work with all Linux programs, ~ and - are features of Bash and only work with Bash and Bash scripts.
I wonder since when "The tilde (~) represents you current directory". And since when "~ and - are features of Bash and only work with Bash and Bash scripts. "
Well-motivated guide to use of Bash for scripting, February 20, 2004
Reviewer: cbbrowne (see more about me) from Scarborough, Ontario, Canada This is pretty comprehensive book that guides the reader on how to use Bash for a wide variety of purposes.
It is very well-motivated; each chapter introduces the area it examines with an interesting anecdote, and presents a reasonably rich set of examples of how to use Bash along with other Unix tools to solve the problem at hand.
It is not solely about Bash; it shows the use of process control tools like ps, kill, and such, text manipulation tools like grep, sort, cut, sed, and such, and version control using CVS. This is all well and proper: One of the major uses of shell scripting is to paste together other programs, and these examples support that.
Well done...
This is not a greatest book for learning Shell Scripting. This book does not cover regular expressions in detail even though regular expression is the heart to learning shell scripting. It could be a good book for users already familiar with Shell scripting and want to learn advance techniques in administering their application or the UNIX system. I will definitely not recommend this for users that are looking to learn and understand Shell scripting. |
I have owned this book since 1996 and I used it as my introduction to Korn shell programming. To the credit of the book, I was able to become very adept at Korn shell and I have written some amazing scripts. However, I must admit that some sections of this book are misleading, confusing and downright incomprehensible. It took many re-readings of some chapters before the author's lesson was brought to light. I would recommend this book as a Korn shell reference, but it is probably not the best place to start for a Korn shell beginner. I am finding this to be true for a lot of the books by O'Reilly & Associates. |
A great book about Korn shell programming, December 3, 2001
| Reviewer: bon_jour (see more about me) from Dallas, TX |
I gave it 5 stars partially because it was given just 1 star unjustly by a few reviewers. From a number of complaining reviews, one realizes that the book title is little misleading. It's not a book for a true beginner wanting to read about "simple" examples of shell programs and looking for detailed explanations line by line. This book is concise, to the point, and really explains "Korn" shell's features. Even as early as chapter 4 about Korn shell basics, things are explained that a long-time shell programmers may not know. If you do and have done serious, real world Korn shell programming, you'll appreciate it.
There were also complains about hard to find things in the book. But from my experience, it's not the case if one really reads it from cover to cover and understands the topics presented chapter by chapter. I agree that the book may not be a great reference book, but it was not written as one.
An excellent book for the beginner - advanced ksh programmer, March 29, 2001
|
|
Reviewer: fishgeeks_dot_com (see more about me) from FishGeeks.com |
This is a great book for someone new to ksh programmer. It should be treated as a work manual and not as a reference book. Read this book through from cover to cover and you'll soon be writing ksh scripts with ease.
The book takes you though Korn shell basics from answer what a shell is to using files, I/O, and character quoting.
From there it goes into command line editing, customizing your environment, and into basic programming. Once through that you learn flow control, arrays, advanced I/O, and process handling.
Finally you learn how to debug the script you just wrote.
As a reference manual this book is average. It's not meant to be a typical "nutshell" book and shouldn't be treated as one.
The bottom line? Buy this book if you are truly interested in learning how to program in the Korn shell
Medinets dedicates nearly half of the book to an ample discussion of the Bash shell and creates special chapters focused on the constituent elements of shell programming, including the creation of variables and procedures. While discussions on Perl and Tcl are separated into distinct chapters, each has fewer code samples to illustrate variations on code writing and usage. Instead, the author supplements the discussions on Perl and Tcl with dictionary-entry-style charts describing each language component by component.
See also ksh93 books and Unix books. IMHO A Practical Guide to Solaris can be used for shell introductory course too, because in such a course utilities are as important as shell itself (although I still prefer ksh93, on the introductory level there is no much difference between, ksh88, bash and ksh93, but you better stay with classic ;-)
With the price below $20 for used book it is a good value to 1K pages.
by Stephen Kochan, Patrick Wood
This is a very solid introductory book from the authors that were in the field for more then 20 years. The first edition was published in 1985 I still have it. It looks like a Guinness record for a computer book: twenty years in print ;-)
Although the content is rock solid this this is still Born shell so it's OK only as an introduction, when both Bash and ksh93 have a disadvantage of being too complex and fat
|
|
Excellent beginner book, July 24, 2001
Reviewer:
James Russell (see more about me)
If you are new to the Korn Shell then this
is a great buy. Start here to learn Flow Control, Regular Expressions,
I/O and command-line processing, background job referencing, and debugging.
This text also covers basic emacs and Vi operations as well as ways
to customize your environment in UNIX.
I picked this book up as a supplement
to learning UNIX. The index proved helpful when I was learning a new
command or searching for a solution to my problem. I like the book because
it is easier to use than trying to scour the web for solutions. This
book will at least narrow the task and help you know what to look for
on the web.
But even with some additions and modifications I would recommend Sobel's book as an add-on to this book. Explanation of various features of the shells in is decent, but order of chapters is somewhat strange and most examples are weak and artificial.
There is also a weaker Linux editon that discuss bash instead of Ksh93.
The book covers too many shells. Despite apologies of the author each redundant chapter adds to the brick size of the book and adds to the cost of the book as well.
***
Need Go Beyond by Example", August 3, 1997
Reviewer: A reader
I am a "not-so-proud"
owner of "Shell By Example" and "Perl by Example" - let me tell you
why. First, the "Perl" book is boring and unfocused. The "Shell" book
is even worse, it has several typos and the book is inflated to 600+
pages - the author uses the same data file in every example and prints
it out in every example every time (There are a lot of examples, as
indicated by the book title)! Second, it (the "Shell" book) does not
provide some useful, interesting, long examples, most of the examples
(scripts) are "baby talk" types - you are more likely to read
them and forget them later. There is no problem-solving section.
There is no reader involvement. In addition, the paper used
in manufacturing of this book is so heavy, it makes this book look like
a 1000+ page book. I bought these books at the same time in a "normal"
bookstore - which means I did not take advantage of 20 % discount from
AMAZON.COM and paying high California Sale Tax.
One of those
"must have" books, June 25, 1999
Reviewer: rjw@pcs-sd.com from South Dakota, USA
It is unfortunate
that the many typos made it into the final product. That aside, I recommend
this book to anybody who wants to know more about shell programming
in general. Although I still have many separate books on awk, sed, sh,
csh, etc. this is the book I started learning Unix on, and this is the
book I still keep on the shelf, or use when I am preparing my own classes
on shells. The layout and content of this book has made me search for
and buy other Quigley titles simply on the strengh of the author's name.
Learning by
example, November 17, 2000
Reviewer:
willem leenen (see more about me) from Amsterdam
The 'Unix Shells By Example' is a well-known book in the field of shell
scripting. It has about 640 pages with a CD-ROM included. The book is
well edited, with good white-spacing and clarity in layout. Having taught
the unix shells for over 15 years, the author really knows her stuff,
and the text is factual and to the point. The index seems complete and
one doesn't have a difficulty in finding the right info one is looking
for. These properties should be normal for books, but computer books
seem often an exception.
The chapters deal about the central Unix-commands for scripting (Grep, AWK, SED) and the big three shells (korn, bourne and C-shell). The author explains the subject in great detail by showing example scripts. First you're given the data or text to be edited, then the script or command lines and finally a lengthy line-by-line explanation of the script syntax. The subjects of the scripts range from explaining the basic Unix-commands to complex intertwining regular expressions, functions, obscure nawk options etc. The author also touches the subject of shell-history, making comparisons of the three shells, giving 'lab-exercises' and some Unix background about command types, login and inheritance. The apparent subject that is missing in this book is the Bash shell, the preferred shell in the Linux community. However, a separate book on this subject is available (Linux Shells By Example). As with all books that have an extensive coverage of the subject, this book too can be overwhelming for the absolute beginners in shell scripting. It takes some time before one writes syntax like:
nawk -F: 'BEGIN{printf("What vendor to check?");\
getline ven <"/dev/tty"};$1 ~ ven\
{print"Found" ven "on record no" NR}' vendor
Instead of searching the pages for the basics, beginners should consider buying an entry level book.
Conclusion: For the intermediate scripter who visits shell sites like shelldorado and lurks newsgroups in search of advanced programming constructs to steal this book is a great find. You won't be left with a feeling that you'll outgrow this book. For newcomers in scripting this should however not be the first book to buy, they're better of with titles like "learning shell scripting in 24 hours". But once through these 24 hours, this book can only be warmly recommended.
Table of contents
This is a weaker version of the Unix shell by examples book. See
my review above. For Linux book it's
a rather expensive book but still it has more than 100 additional pages
in comparison with Unix edition for the same price ;-).
This book contains a lot of exercises but the author seems to be not seeing the forest after the tries and is unable to distinguish between important features/topics and obscure one. CD contains full CBT training course that costs much more than the book if you want to buy it separately.
Best shell scripting guide since Kochan , September 16, 1999
Reviewer: A reader from
Glad to see the other good reviews. I was impressed
and wanted to see what others had to say.
This is the way it should be done. Definitely appreciated the emphasis on the bash shell and the inclusion of other useful tools. Pleasantly surprised by the depth and quality of the examples...this is one of the best book in SAMS catalog. Author also had a chapter or two in Kao's Special Edition Using Unix, which was a solid book even though it is a major doorstop in size. Looking forward to more titles from Veeraraghavan.
It looks like the quality of non-O'Reilly titles may be improving after all...
A nice introductory but closer to an intermeduate book. Contents is slightly outdated and covers only ksh88. Still the first edition is somewhat better then the second that was upgraded by a different author. The key factor for this book is the right definition of intended audience: it is really the best introductory book for students at the university level and professionals. Reader needs to know some Unix (and the reader is expected to know classic Unix utilities) or programming experience.
Actually it is one of the few shell books that provides a good
coverage of usage of pipes in shell scripting, the quintessential
feature of the Unix shell. This is the strongest feature of the
book. At the same time the books also contains a lot of subtle but
important information for example it explains why an alias ll='ls
-la ' (with trailing space) is more useful then without trailing
space. It also covers "IFS" variable, shell functions. In
several chapter the authors develop the example of a simple, yes
(marginally) useful tool: an analog of C-shell popd/pushd/dirs troika
for the ksh. the last chapters contains an example of a really complex
(shell debugger) script.
Paradoxically the first edition is considered to be weak by some
Amazon.com readers: IMHO this is a nice demonstration of an "Amazon
lemmings effect". May be the reason is that the book is too complex
to be the first book for learning shell, if you are complete novice
(often shell course introduces people to Unix at universities).
In such cases A Practical
Guide to Solaris might be a better bet, but still I recommend
to buy this book as a second book -- it contains a lot of important
information that helps better understand shell and write better
shell scripts. The second edition should be available in April
2002, and with 9 years and 40 pages we can expect a lot of improvements
;-)
Shortcomings of the book include very superficial treatment of
.profile and .kshrc files. Some examples also can be made batter
(I think that pushd/popd example that authors use can be replaced
by something more useful) but that can be said almost about any
book. Neither sed not awk is covered (O'Reilly has a separate
book on this subject). At the same time the fact that book does
not use awk cripple some examples as it solves several shell
problems more elegantly than other built-in UNIX commands.
My Review
IMHO this is one of the best ksh93 intermediate books, that can also serve as the first book on shell programming for people with some exposure to Unix or programming. It concentrates more on the language than on typical examples of shell scripting. See reviews in a Introductory Shell Programming section). It contains the code for a Korn shell debugger: a non-trivial exercise...
This book should probably be called "Shell by example" but this title was already taken. It looks like it is slightly AIX biased but many scripts are multiplatform and take into account all major enterprise flavors of Unix including Solaris, HP-UX and Linux.
The book deals with POSIX shell not ksh93 as previous reviewer assumed (for example Solaris the default shell is POSIX shell and ksh93 is available only as dtksh, the Desktop KornShell)
The books starts with very brief, badly written and superficial reference of shell, that should probably be published as an Appendix.
The other 24 chapters demonstrate "shell by example" approach: each is devoted to one useful, semi-useful or completely useless example.
Chapter 2 is amusing. The author shows 12 ways of piping the file into the while loop. Half of them completely useless and added just to impress the reader. Moreover the author seems does not understand that
cat $FILENAME | while LINE=`line`
and
cat $FILENAME | while LINE=$(line)
are absolutely identical :-)
Chapter 3 is semi-useful and is devoted to programming of various type of progress indicators in shell. All example are pretty straightforward.
Chapter 4 is devoted to monitoring filesystem space. For an intermediate book it's sad that the author definitely does not understand that he need to use AWK or Perl here.
Chapter 5 is good and shows simple and useful swap space monitoring framework.
Chapter 7 contains very questionable approach to a trivial problem. Instead of parsing uptime string with AWK or Perl from the right the author split hears about variations of time formats used in the command.
Chapter 8 demonstrates co-routine approach to solving a problem and that's probably the most interesting example that I have found. But the code in Listing 8.9 to long and can benefit form refactoring.
Chapter 10 is useless other then example of some shell constructs and the author does not demonstrate deep understanding of the issues involved with security of passwords in general and with the randomization of passwords in particular.
Chapter 11 is AIX specific.
Chapters 12 and 13 are pretty useful, but in both cases there are better approaches and they can benefit from Webliography inclusion (the author actually pretty much ignore the fact of existence of Internet including various free code databases like freshmeat).
All-in-all the book is a mixed bag. Examples are OK as shell programming demonstrations but they fall short of demonstrating the mastery of both ksh and UNIX tools involved.
This is not a greatest book for learning Shell Scripting. This book does not cover regular expressions in detail even though regular expression is the heart to learning shell scripting. It could be a good book for users already familiar with Shell scripting and want to learn advance techniques in administering their application or the UNIX system. I will definitely not recommend this for users that are looking to learn and understand Shell scripting. |
When I read programming manuals, I usually skip over the text and head straight for the examples. I like short, focused examples that don't bog me down in a lot of programming red-herrings. And when I am forced to read text, I like a little humor.
So, I wrote the kind of book that I like to read.
Here are some Amazon readers reviews:
Reviewer: A customer from New Jersey
The KornShell Programming Tutorial should be the model for all technical books. It is well organized and extremely well written. The book provides a ton of examples, and output is provided for each one--what a concept! Reading this book has enabled me to write support and debugging scripts for the program I currently work on, and if I need to refer to the book, I can find the topic quickly. The writing style is crystal-clear and right-to-the-point, and the humorous touches round out everything nicely. Thanks to Barry Rosenberg for caring enough to write a book on Korn Shell programming that a novice could actually read, understand, and apply.
All in all - I give it 3.5 stars. 4 stars with correct
editing and proofing. 4.5 stars if co-processes were covered extensively.
5 stars if he gets rid of the jokes --- (ok, I'm kidding there).
gtillery@mindspring.com
from Birmingham, Alabama , January 10, 1999 *****
Another #1 'Must Have' Book For Any Serious SysAdmin
Barry Rosenberg has done it again. This time with more flair and
vision for what Kornshell can do! I purchased his original book on Kornshell
and practically wore the cover off of it. He has taken a great book
and made it even better! I will recommended this one to everyone I can
talk to as well. Looks like this new edition will replace his other
book on my bookshelf. Simply Outstanding!
There is no one better than Mr. Korn himself to offer the clearest, most complete information about KornShell. The usefulness of this book as a language reference is indisputable. Although not immediately comprehensible by the novice, it is, nevertheless, essential to all KornShell programmers. The back cover index is one of the nicest features of the book. I only wish more books would use this design. Every new technology should have major technical reference material written by its inventor or creator available to the general public. In the UNIX world, such works are common. I enthusiastically recommend this book for all KornShell programmers. For those that find it difficult initially, I assure you that you will grow into it, and it will eventually find its place close at hand in your office library.
Desktop
KornShell Graphical Programming by J. Stephen Pendergrast, Jr.
Addison-Wesley, 1995. Covers ksh93, the authoritative reference on dtksh.
- Appendix X- The Shell Filter Builder (Lex is lexical analyzer generator. Generated programs can read files, interpret and transform them quickly. Lex is an very good tool for building fast custom filters that can be used with the Shell)
- Appendix Y- Nroff and Troff ( Nroff and Troff are the old document processing language of UNIX Shell)
- Appendix Z - Regular Expressions
Ray Swartz / Published 1990
There is no one better than Mr. Korn himself to offer the clearest, most complete information about KornShell. The usefulness of this book as a language reference is indisputable. Although not immediately comprehensible by the novice, it is, nevertheless, essential to all KornShell programmers. The back cover index is one of the nicest features of the book. I only wish more books would use this design. Every new technology should have major technical reference material written by its inventor or creator available to the general public. In the UNIX world, such works are common. I enthusiastically recommend this book for all KornShell programmers. For those that find it difficult initially, I assure you that you will grow into it, and it will eventually find its place close at hand in your office library.
Anatole Olczak / Paperback / Published 1998
Arnold Robbins / Paperback / Published 1995
Bruce Blinn / Paperback / Published 1995
The next several chapters cover shell utilities, including the important and mysterious "IFS" variable, shell functions, and examples of complete and marginally complex shell scripts. The functional explanations are all quite good, and the sample scripts are often useful themselves, and they do a good job of illustrating the use of the concepts presented in preceding chapters.
The next two chapters, on debugging and specific portability issues, are very well thought out and are far and away the best sources of this information I have seen in print. This information is excellent and even an expert shell programmer will almost certainly find something of significant value here. These chapters are followed by a list of common problems and resolutions that shell programmers commonly face. This information is also extremely useful, and it's likely that they will impart significant understanding to most readers. The book ends with a comparison of shells and a summary of the Bourne shell syntax.
The only major downside to this book is it's price. For its size, $40 seems a bit steep to me, but given the quality of the material in the book, it's really quite a bargain. I recommend that every shell programmer should own Portable Shell Programming along with their well worn copy of K&P. I don't think it's necessary to purchase any other books on the topic.
As opposed to other books with "practical" in the title,
this one lives up to its name. I found Chapters 4 (Using Files),
5 (The Environment), and 7 (Using Filters) very helpful. The
book is full of many examples of practical things, such as how
to delete all blank lines in a file. This makes is valuable
for the beginner, and the later chapters contain information
for the more advanced shell programmer. I got this book at a time when the guy who wrote all our
shell scripts quit without notice. This book was a lifesaver,
as I had to write short (and not so short) shell scripts to
automate certain tasks & understand the work he did. I would like to see more discussion in Chapter 7 (Using Filters)
about combining the use of sed and the Unix/Linux command tr.
I find that I have to use these together sometimes as one does
things the other can't handle. This is the only suggestion I
have to improve an already useful book.
If you've done any intoductory shell programming at all, this book will get you started in more serious shell programming efforts. I only gave this book 4 stars although it really deserves more, because it may not live up to the expectations of some readers. Only the Bourne shell is covered, because it's the most portable. It covers all the basics and many advanced issues. The authors philosphy is to teach by example, and this book is full of examples and sample code. The first half of the book is a down and dirty "How To by Example." The examples are general enough and well enough documented that the use for the syntaxes described remains clear in the readers mind. The second half of the book contains some sample shell utilities. These are shell programs that were written to mimmick or epxpand on functionality of common UNIX commands. I found the first half of the book to be the most useful over time. Some explanations may be a bit terse for brand new shell
prgrammers. Awk is covered in much detail at all, although there
are some very nice examples of using sed. All in all this is
the best shell programming reference I've seen.
The author starts off with the assumption that the reader
is technically savvy but has no knowledge of shell scripting.
This means that the first chapter necessarily covers basic Variable are covered comprehensively in Chapter 2. This chapter covers all the ways of declaring, initializing, assigning and passing variables. It also covers the Borne shell special variables, such as $?, $$, etc. I learned some new techniques for handling uninitialized variables using special Borne shell syntax, such as "". This statement causes the script to print out the "message" and then terminate if the "variable" is not initialized. The author next covers shell functions and built-in commands
available in Borne shell. The 3 pages on shell functions is
adequate to illustrate function syntax. The author also does
an adequate job of examining function parameters, variables
in functions, strategies for reusing functions and the different
effects from executing a function in the current shell versus
a subshell. The rest of the book shows numerous examples of
functions, so the lack The point of most shell scripts is to manipulate files, so
I consider the material in Chapter 4 crucial. This chapter does
a fine job of explaining the file descriptors (0,1,2) and redirection
of input and output. The author then discusses opening, writing,
reading, Borne shells usually depend on the fact that they are running on a Unix-like system. In other words, most shell scripts interface with the operating system. Chapter 5 details how Bourne scripts interact with the environment they are running in. Coverage includes Environment Variables, child versus parent environments, getting user and system information, using signals, and, finally, remote commands. The coverage is not comprehensive, nor could it be. It would take volumes to comprehensively cover the UNIX environment in relation to shell scripts. With that said, the author presents a respectable subset of the most important topics. The next short chapter first reviews the UNIX command line conventions, e.g. "command [options] [parameters]". The author then discusses the getopt(s) commands for parsing command line parameters and what to do when these commands are not available. Filters are commands that get their data from the standard input, perform some transformation on the data, and then write the data to the standard output. More than one filter can be strung together to perform very complex transformations. This chapter presents an introduction to this important topic. The tools illustrated are pipes, sed and awk. This chapter, again, only presents an introduction. But the number of examples is impressive and so is the categorization. With this chapter, Chapter 8 and the man pages for sed and awk, a reader will be in a position to infuse his shell scripts with considerable power. Chapter 9 and 10 are the culmination of the previous 8 chapters. Chapter 9 provides a library of shell functions that I found highly instructive. The list of functions are: CheckHostname, Clear, DownShift, FullName, GetYesNo, IsNewer, IsNumeric, IsSystemType, Prompt, Question, StrCmp, and, finally, SystemType. The author presents an assortment of shell scripts that are written to be both instructive and useful. As with the functions in Chapter 9, I found these to be highly instructive. The list of scripts are: Cat, DirCmp, Kill, MkDir, Shar, Wc, addcolumn, dircopy, findcmd, findfile, findstr, hostaddr, and, finally, ptree. No programming language guide would be complete without the obligatory coverage of debugging. This is an area of personal interest to me, because my experience in the industry has taught me that few programmers leave the university with adequate debugging skills. The art of debugging boils down to a set of heuristics for reproducing or capturing an error, narrowing down the potential causes to a manageable set of candidates, and then progressively simplifying until the exact cause of the problem can be understood and corrected. This chapter will not teach the reader to be a competent debugger. The chapter does illustrate common pitfalls that shell scripts contain. It also discusses the basic elements in tracing through a script and even touches on shell scripting style as a tool to reduce bugs. All good, common sense information. Considering the title of the book, it would be expected that
there would be a chapter on portability. This chapter presents
some of the best material I have seen assembled on writing portable
shell scripts. The author discusses System V versus BSD, subsets
of commands, abstraction, locating commands and files, shell
features, issues with a number of specific commands, and file
and path names. If you are writing production scripts that may
be shipped in a heterogeneous environment, this is required
reading.
Bruce Blinn has written a very useful, highly practical shell programming book. I am working my way through the book but even after a chapter or two I have started to apply the priceless nuggets I was able to glean. If you work in a Un*x environment and need to script tedious tasks to allow you more time to get on with the fun stuff, then this will help you. It is well written and as easily understood as you can reasonably
expect when you consider the arcane subject matter.
1 of 3 people found the following review helpful:
This is a great book. It gets straight to the point, covers
everything there is to know about the bourne shell and uses
the least amount of words to do it. The author has done a fantasic
job! |
This is one of the oldest good shell books. First edition was published in 1987 I think. It's interesting to see what people know about shells in late 80th. This is also a book written by the author who knows C well (Stephen G. Kochan also wrote Programming in ANSI C and that shows): the trait lost in later generation of shell book authors ;-)
Have taught and used this book for over 5 years., 16 November,
1998
Reviewer: A reader from Tampa, Fl.
I teach at a small college. My students
have are inexperienced UNIX users. They love the book. The examples
are understandable and helpfull.
I use the book as a reference. I find it equally invaluable. It sits on my bookshelf and is used almost daily. Both myself and my students find this book invaluable for new learning and reference.
Dated, but fantastic, May 31, 2001
Reviewer:
alex j. avriette (see more about me) from washington, dc
I am a perl and C programmer, and I am very familiar with the shells
outlined in this book. So the material was not particularly "new" for
me. I can see how it would be difficult to understand for a user who
was new to shell programming.
If the intended audience is the intermediate unix user who knows something of programming, this book gets a full 5 star, my seal-of-approval rating. Terrific.
One thing it is lacking is a brief mention
of perl or of awk. In many cases, it is simpler to write:
instead of:
or, at least from the standpoint of understandability and readability. but the book doesnt claim to be a manual for awk, and O'Reilly has an excellent book on the subject.
I continually recommend this book to
people, and where ever I go, I find this book on the bookshelves of
successful people.
After a quick review of the basics of UNIX, the authors give a purely descriptive explanation of the UNIX shell in chapter 3. Emphasizing that it is an interpretive language, the most commonly used shell commands are discussed in chapter 4, starting with a discussion of regular expressions. The cut, paste, sed, tr, grep, uniq, and sort commands are treated in detail.
In chapter 5, one begins the actual task of creating shell programs using shell variables. There is no data typing in the shell, so values can be assigned to variables without noting their type as integer, float, etc. The authors only briefly discuss the mechanism in shell programming. The method by which the shell interprets quotation characters is covered in the next chapter. The single, double, backslash, and back quote characters are discussed in detail. Noting that arithmetic operations are done on values stored in variables in the shell, the authors show to proceed with these operations using the expr program.
The mechanisms for passing arguments to shell programs is treated in chapter 7, the authors showing how to write shell programs that take arguments typed on the command line. The role of positional variables for delaying assignment after normal command line processing is discussed. The $#, and $* variables are discussed briefly, with $# getting set to the number of arguments typed on the command line and $* used for programs taking a variable number of arguments. The shift command is explained well as a method to allow one to use more than nine arguments to a program.
The ability of shell programs to execute decision blocks is treated in chapter 8, via the if statement. The role of the test and exit commands are in if blocks are discussed in good detail. In addition, the case command, familiar to C programmers is introduced as a technique to allow a single value to be compared against other values. The && and || constructs are used to show the reader how to execute commands that are contingent on the success or failure of the preceding command.
Program loops, via the for, while, and until commands are discussed in chapter 9, followed in the next chapter by a discussion of how to read data from the terminal or from a file using the read command. The ability to perform I/O redirection is discussed also.
Local and export variables are discussed in the next chapter on the user environment, and the authors give a good summary of how these work in shell programming. More discussion on parameter passing is done in chapter 12, with the different methods of parameter substitution given detailed treatment. The authors show how to use the $0 variable to check whether two or more programs have been executed, and how to use the set command to set shell options and to reassign positional parameters. This is followed in the next chapter by a discussion of the eval command, which makes the shell scan the command line twice before executing it, and the wait command, which will allow serialization in program execution. The trap and type commands are discussed also.
The Korn shell is discussed in chapter 15, with emphasis on the features added to Korn shell that cannot be found in the Bourne shell. The vi and emacs capability of this shell is briefly discussed in this chapter. The differences between Korn shell functions and Bourne shell functions are discussed in detail by the authors. Most importantly, the ability of the Korn shell to do integer arithmetic without using the expr command is discussed via the let command, which is built-in to the Korn shell. Also, the capability of the Korn shell to support data typing is discussed, along with its pattern matching capabilities. Pattern matching is done most efficiently now using Perl however.
David Ennis, James C., Jr. Armstrong / Paperback / Published 1994
Gail Anderson, Paul Anderson / Paperback / Prentice Hall /ISBN: 0-13-937468-X
Copyright © 1996-2009 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
Disclaimer:
Last modified: August 11, 2009