Exforsys.com
 
Home Tech Articles UNIX
 

Teach Yourself Shell Programming in 24 Hours

 

We assume that you have some familiarity with UNIX and know how to log in, create and edit files, and work with files and directories to a limited extent. If you haven't used UNIX in a while or you aren't familiar with one of these topics, don't worry. The book reviews this material thoroughly. This book is divided into three parts:

- Part I is an introduction to UNIX, the shell, and some common tools.
- Part II covers programming using the shell.
- Part III covers advanced topics in shell programming.

Part I consists of Chapters 1 through 6. The following material covered in the individual chapters:

  • Chapter 1, "Shell Basics," discusses several important concepts related to the shell and describes the different versions of the shell.

  • Chapter 2, "Script Basics," describes the process of creating and running a shell script. It also covers the login process and the different modes in which the shell executes.

  • Chapters 3, "Working with Files," and 4, "Working with Directories," provide an overview of the commands used when working with files and directories. These chapters show you how to list the contents of a directory, view the contents of a file, and manipulate files and directories.

  • Chapter 5, "Manipulating File Attributes," introduces the concept of file attributes. It covers the different types of files along with modifying a file's permissions.

  • In UNIX every program runs as a process. Chapter 6, "Processes," shows you how to start and stop a process. It also explains the term process ID and how you can view them.

By this point, you should have a good foundation in the UNIX basics. This will enable you to start writing shell scripts that solve real problems using the concepts covered in Part II. Part II is the heart of this book, consisting of Chapters 7 through 18. It teaches you about all the tools available when programming in the shell. The following material is covered in these chapters:

  • Chapter 7, "Variables," explains the use of variables in shell programming, shows you how to create and delete variables, and explains the concept of environment variables.

  • Chapters 8, "Substitution," and 9, "Quoting," cover the topics of substitution and quoting. Chapter 8 shows you the four main types of substitution: filename, variables, command, and arithmetic substitution. Chapter 9 shows you the behavior of the different types of quoting and its effect on substitution.
  • Chapters 10, "Flow Control," and 11, "Loops," provide complete coverage of flow control and looping. The flow control constructs if and case are covered along with the loop constructs for and while.

  • Chapter 12, "Parameters," shows you how to write scripts that use command line arguments. The special variables and the getopts command are covered in detail.

  • Chapter 13, "Input/Output," covers the echo, printf, and read commands along with the < and > input redirection operators. This chapter also covers using file descriptors.
  • Chapter 14, "Functions," discusses shell functions. Functions provide a mapping between a name and a set of commands. Learning to use functions in a shell script is a powerful technique that helps you solve complicated problems.
  • Chapters 15, "Text Filters," 16, "Filtering Text Using Regular Expressions," and 17, "Filtering Text with awk," cover text filtering. These chapters show you how to use a variety of UNIX commands including grep, tr, sed, and awk.

  • Chapter 18, "Miscellaneous Tools," provides an introduction to some tools that are used in shell programming. Some of the commands that are discussed include type, find, bc, and remsh.

At this point, you will know enough about the shell and the external tools available in UNIX that you can solve most problems. The last part of the book, Part III, is designed to help you solve the most difficult problems encountered in shell programming. Part III spans Chapters 19 through 24 and covers the following material:

  • Chapter 19, "Dealing with Signals," explains the concept of signals and shows you how to deliver a signal and how to deal with a signal using the trap command.

  • Chapter 20, "Debugging," discusses the shell's built-in debugging tools. It shows you how to use syntax checking and shell tracing to track down bugs and fix them.

  • Chapters 21, "Problem Solving with Functions," and 22, "Problem Solving with Shell Scripts," cover problem solving. Chapter 21 covers problems that can be solved using functions. Chapter 22 introduces some real-world problems and shows you how to solve them using a shell script.

  • Chapter 23, "Scripting for Portability," covers the topic of portability. In this chapter, you rewrite several scripts from previous chapters to be portable to different versions of UNIX.

  • Chapter 24, "Shell Programming FAQs," is a question-and-answer chapter. Several common programming questions are presented along with detailed answers and examples.

Each chapter in this book includes complete syntax descriptions for the various commands along with several examples to illustrate the use of commands. The examples are designed to show you how to apply the commands to solve real problems. At the end of each chapter are a few questions that you can use to check your progress. Some of the questions are short answer while others require you to write scripts.

After Chapter 24, three appendixes are available for your reference:

  • Appendix A, "Command Quick Reference," provides you with a complete command reference.

  • Appendix B, "Glossary," contains the terms used in this book.

  • Appendix C, "Quiz Answers," contains the answers to all the questions in the book.

Click here for the book.


Read Next: Advanced Bash-Scripting Guide with Sample Code



 

 

Comments


rampratap said:

  :) Hi!
I need tutorial on Telecom networking
September 28, 2004, 9:25 am

faisal1520 said:

  i want to learn network programming on unix
March 26, 2005, 10:50 pm

bedo said:

  hi,

i want to learn shell programming so i need the book.

Could you please help me at this point. i can\'t down \"Teach Yourself Shell Programming in 24 Hours \"


July 15, 2005, 10:03 am

Raj Kumar Jain said:

  Need the book which can give me entire idea of Unix
December 15, 2006, 7:47 am

venkat.s said:

  Can any one provide me SQL / Crystal Report programming Question along with answer.
May 5, 2007, 12:38 am

jestin said:

  i want to know different types of simple programs with source code in shell programing
November 2, 2008, 3:48 am

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2010 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape