Miscellaneous

  Home arrow Miscellaneous arrow Control Mechanisms of the UNIX Shell
MISCELLANEOUS

Control Mechanisms of the UNIX Shell
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2009-05-06

    Table of Contents:
  • Control Mechanisms of the UNIX Shell
  • The true/false statement
  • The if control statement
  • The expr command

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Control Mechanisms of the UNIX Shell


    (Page 1 of 4 )

    The power of an operating system is equal to the powers of the tools/programs it can provide. What you can do inside the operating system depends on the nature of the tools it offers you. However, you can have the most advanced and capable tools, yet suffer if you fail to put them to work in a correct and efficient way. This is where the control mechanism you have at your disposal enters the picture. Now then, what control mechanism will help us to exploit UNIX tools to their full capacities?

    This article is part of a larger series in which I try to cover everything you should know about UNIX Shell programming. The knowledge you can amass here will be very helpful once you start to use UNIX-based operating systems like UNIX itself, FreeBSD, and so on.

    With the tools/commands inside the UNIX Shell, you can automate most basic tasks and perform some advanced ones. If you had to do these tasks manually, with the mouse and a graphical interface, they would take much longer. So why waste your time?

    When we talk about a concrete task to complete in the shell programs, in fact, we have a command or a command line that waits for execution. With command lines, we can give more than one command with the help of pipes, as I will be explaining in an article entitled Data Streams and the UNIX Shell. Due to this, we often refer to a concrete task as a pipeline. Pipelines are a sequence of commands connected via pipes.

    In the control mechanism, a task is a command line. If, inside the command line, the performance of another command depends on the result of an assumption, we call that a command line condition. The order in which the commands are executed we call the controlling mechanism. For this, the shell uses a couple of control structures.

    If you've encountered other structured programming languages, you already know that the control mechanism should implement two basic types. One type is decision implementation (the if-then-else structure) and the second is loops. With the help of these two, we can simulate the control of any program.

    The creators of the UNIX Shell were inspired by the control mechanism of  ALGOL68. In the following articles, I will present to you all the structures that help us in implementing these two basic control mechanisms and how you can  exploit them to their utmost. In this first article on the topic, I will look at  decision making.

    More Miscellaneous Articles
    More By Gabor Bernat

    blog comments powered by Disqus

    MISCELLANEOUS ARTICLES

    - Oracle Database XE: Indexes and Sequences
    - Modifying Tables in Oracle Database XE
    - Oracle Database XE: Tables and Constraints
    - More on Oracle Databases and Datatypes
    - Oracle Database XE Datatypes: Datetime and L...
    - Oracle Database XE Datatypes: Character and ...
    - From Databases to Datatypes
    - Firefox 3.6.6 Released with Improved Plug-in...
    - Attention Bloggers: WordPress 3.0 Now Releas...
    - Reflection in PHP 5
    - Inheritance and Other Advanced OOP Features
    - Advanced OOP Features
    - Linux from Scratch V.6.6 Review
    - Linux Gaining in Strength
    - Install Slackware on Your Old PC


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap