Miscellaneous
  Home arrow Miscellaneous arrow Control Mechanisms of the UNIX Shell
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
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

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    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


     

    MISCELLANEOUS ARTICLES

    - Using PHP to Stream MP3 Files and Prevent Il...
    - 10 Must Have Firefox Improvements
    - All About OpenOffice 3.0
    - Shell Script Writing
    - Loops in the UNIX Shell
    - The Test in the UNIX Shell
    - Data Streams and the UNIX Shell
    - Control Mechanisms of the UNIX Shell
    - Variables Within the UNIX Shell
    - The Shell and UNIX
    - In Detail: UNIX File Systems
    - Rights Management in UNIX
    - UNIX File Systems
    - The Terminal in UNIX
    - Operating Systems and UNIX





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    Stay green...Green IT