UNIX Shell Programming

Overview

Thoroughly updated this expanded edition will improve productivity and save time for power users. Features the latest data on the popular Bourne, C and Korn Shells. Explains how to maximize the power of UNIX through Shell programming, create software tools to simplify routine work and step behind the facade of the Graphical User Interface (GUI) to tap the potency of UNIX and Shell. Includes more substantial introductory material, an expanded Shell tutorial and a complete ...
See more details below
Available through our Marketplace sellers.
Other sellers (Paperback)
  • All (10) from $1.99   
  • New (1) from $374.07   
  • Used (9) from $1.99   
Close
Sort by
Page 1 of 1
Showing All
Note: Marketplace items are not eligible for any BN.com coupons and promotions
$374.07
Seller since 2007

Feedback rating:

(144)

Condition:

New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

New
Paperback in excellent condition.

Ships from: Erie, CO

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
Page 1 of 1
Showing All
Close
Sort by
Sending request ...

Overview

Thoroughly updated this expanded edition will improve productivity and save time for power users. Features the latest data on the popular Bourne, C and Korn Shells. Explains how to maximize the power of UNIX through Shell programming, create software tools to simplify routine work and step behind the facade of the Graphical User Interface (GUI) to tap the potency of UNIX and Shell. Includes more substantial introductory material, an expanded Shell tutorial and a complete reference section.


Revised and updated coverage of the Bourne, Korn, C, and BASH shells, includes Internet and business application scripting. Guides you from simple shell scripts for novices, to advanced scripting for administrators. Covers shell fundamentals, commands, decisions, and repetition, then leads you through user shell programming and structuring concepts. Shows how to prototype and reuse shells. Discusses shell database and system integration, reliability and portability issues, administrative and maintenance duties. Good logically-organized tutorial that first teaches basic skills of shell scripting, then shows how to use these newly acquired skills in productive applications.

Read More Show Less

Editorial Reviews

From Barnes & Noble

Fatbrain Review

Revised and updated coverage of the Bourne, Korn, C, and BASH shells, includes Internet and business application scripting. Guides you from simple shell scripts for novices, to advanced scripting for administrators. Covers shell fundamentals, commands, decisions, and repetition, then leads you through user shell programming and structuring concepts. Shows how to prototype and reuse shells. Discusses shell database and system integration, reliability and portability issues, administrative and maintenance duties. Good logically-organized tutorial that first teaches basic skills of shell scripting, then shows how to use these newly acquired skills in productive applications.
Booknews
New edition of a guide to Bourne, C, and Korn--the keys to productivity and quality in the UNIX environment. Annotation c. Book News, Inc., Portland, OR (booknews.com)
Read More Show Less

Product Details

  • ISBN-13: 9780471518211
  • Publisher: Wiley
  • Publication date: 7/28/1990
  • Edition description: 2nd ed
  • Edition number: 2
  • Pages: 288

Meet the Author


Lowell Jay Arthur is President of the Foundation for Advanced Software Technology, Inc. He is a well known lecturer on the subject of large-scale software development, maintenance, and metrics. Jay is also the author of UNIX Shell Programming and Software Evolution, a key component of a successful software creation environment.
Read More Show Less

Read an Excerpt


Chapter 8: Structuring Shell Programs

Function Execution

After declaring your function it is a simple matter to execute the function; simply type the name of the function just as you would any other command. The Shell locates the function and executes the associated commands. While this is very similar to using other Shell commands or Shell programs that you have written, there are differences.

once the function is declared it is stored in your environment and is executed directly. This differs from the typical command where the Shell must read the file and then interpret the commands contained in the file. This is much more demanding and thus much slower than a function call.

Commands stored in a function are not executed in a subshell; they are executed in your current Shell. This is very similar to invoking a Shen program with the dot (.) command:

. shell_pgm

where the shell_pgm is some Shell procedure that you (or someone else) have created. if you recall, this command tells the Shell to execute the command in your current Shell environment. This is different from invoking the Shell directly, which causes the commands to run in a subshell. Since functions are executed in your current Shell, any changes to the environment performed in the function are permanently made to the current Shell. Upon return from the function execution, the changes made to the environment remain intact. Most important, the following changes remain in effect after return from the function call:

1. Any changes to any variables. This means setting of variables, unsetting, and exporting. Basically, any changes to any variables are permanent.
2. Any changes to the current directory remain in effect.
3. Any files used are also shared.

So use care when you execute a function call. it does behave differently from a normal Shell program call.

The commands in the function are executed until either the end of the function is reached, or an exit or return statement is encountered. if an exit statement is coded in your function, then both the function and the invoking Shell are exited. (We have seen previous examples of the exit command.) The return statement is a way to exit just the function with the option of returning some particular value. The syntax of the return statement is: return n, where n is an integer value that you would like returned as an exit status to the calling Shell. This value can be tested for using the $? variable to check to see what action the function performed. Did it complete properly or does some other action need to be taken? The return statement provides the ability to leave a function whenever you choose. For example, if some error condition occurs you can return from the function and inform the calling Shell program that some problem has occurred. If you do not supply a return statement and the end of the function is reached, then an implied return is performed with the exit status equal to the exit status of the last command performed in the function. This is also true if you provide a return statement with no value for n. The last executed command provides the return code. After completion of the function you are returned to the spot where the function was called from. If this was the command line, then you are returned to the command line. If the function was executed from within a Shell program, then a return starts execution at the line following the function call in the program.

If your function has an error when processing under the Bourne Shell, then the function and its calling Shell are exited.

Passing Arguments to Functions

Arguments are passed to functions in the same manner as any other Shell procedure. Simply type the arguments following the command name, in the normal fashion, and the function will be able to access these arguments in the variables $1 ... $9 in the case of the Bourne Shell. Of course, the Korn and Bash Shells can access variables beyond $9, as was discussed previously.

There is one small anomaly that you should take note of. When you call a function with arguments from inside a Shell program, the function arguments replace the arguments originally passed to the Shell program. of course, the solution to this problem is to store the arguments in a variable before you make the call to the function and then, upon return, replace the arguments if there is a need to do so. This can be done using the set command.

Another related approach is to parse all the arguments prior to any function calls and store any arguments in your own variables. The nice thing about this approach is that you can assign arguments to variable names that have more meaning than $1, $2, and so forth. When your programs start to get large and filled with numerous function calls and calls to other Shell programs, it is easy to lose track of what is being stored in the special variables $1 through $9. Good variable names are a key to easy understanding and maintenance of any program. Even though this approach is preferable, it may not always be possible. in those cases, the first approach of storing the arguments and then restoring them ran always be used.

Function Scope

Functions declarations have rules about where the functions themselves are applicable and what variables are accessible to the functions while they are executing. These rules are referred to as scoping rules.

When using the Bourne Shell, function declarations are local to the Shell in which they are defined. This means that any Shell program that runs in a subshell will not have access to the functions that were defined in the parent calling Shell process. in other words it is not possible in the Bourne Shell to export functions to make them available to called Shell procedures.

Once a function begins executing, there is the issue of which variables are available to the function. Since functions run in the current Shell, all variables defined in the current Shell procedure are available to all the functions declared in that Shell process. Also, any arguments passed to the function are available to the function in the special variables $1..$n as was mentioned before. Also, any variables defined in the function itself become available to the calling Shell procedure as well as to all other functions which may be called. Variables that participate in this kind of global sharing are called global variables. They are shared globally between all functions and procedures. By exporting a variable you make it global not only to functions but also to any Shell programs that run in a subshell.

When using the Bourne Shell, all traps are shared between the calling Shell program and the function. Thus, if a trap is reset in a function, it is reset for the calling Shell as well. The exit trap (signal 0) is not activated in the Bourne Shell when a function returns. This is not entirely true for the Korn Shell....

Read More Show Less

Table of Contents

About the Authors
Preface
Pt. 1 Shell for the Novice 1
1 The Power of Shell 3
2 UNIX Basics 15
3 Shell Fundamentals 33
4 Shell Commands 69
5 Shell Decisions and Repetitions 113
6 Shell Programming 157
Pt. 2 Shell Programming for the User 219
7 User Shell Programming 221
8 Structuring Shell Programs 261
9 Internet and the Shell 279
10 C Shell 297
Pt. 3 Shell Programming for the Power User 311
11 Rapid Prototyping and Reuse 313
12 Shell for Programmers 349
13 The Shell Innovator 369
14 Shell Mastery 391
15 The UNIX System Administrator 407
App. A Reusable Shell Code 423
App. B C Language Prototype 425
App. C Makefile Prototype 427
App. D Shell Syntax 429
App. E Shell Built-in Commands Reference 433
App. F Sed Reference 489
App. G Awk Reference 497
Bibliography 509
Index 513
Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)