Server Administration
  Home arrow Server Administration arrow Regular Expressions in 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? 
SERVER ADMINISTRATION

Regular Expressions in the Unix Shell
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2009-06-10

    Table of Contents:
  • Regular Expressions in the Unix Shell
  • Extended Regular Expressions
  • Explaining and Examples
  • The grep 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


    Regular Expressions in the Unix Shell


    (Page 1 of 4 )

    Searching. Now there is a task I am sure you do on a daily basis. In Shell programming, searching is very important; fortunately, you have a reliable set of tools to help you out. These are the regular expressions. And this article is the thirteenth in a series focusing on various aspects of UNIX.

    These are bound mostly to text processing. Because the universal language used in UNIX is the shell, regular expressions come to play an important role when you work under any kind of operating system based on the UNIX shell. A regular expression is a text pattern matching language. Although initially it was first used and developed in UNIX, today it is used in other contexts as well.

    In fact, regular expressions are the number one tool used in most text-handling programs. They are used for pattern matching in domains such as genetic codes, web development and more. This means that  regular expressions have managed to become close to the perfect tool. Nevertheless, this was the result of years of improvement. As you would expect from something that has been around and improved upon for that long, there are a couple of versions.

    First, there is the basic version from which all regular expressions began. After a while, POSIX standards for the regular expression were defined. With this definition, regular expressions gained a little addition and improvement, creating the extended version.

    At the end of the 90s, a powerful script language emerged under the name of Perl. This language contributed its own additions and modifications to regular expressions. This is how the Perl-compatible regular expression appeared. Today we only use the basic version, to maintain backward compatibility with the older scripts. You will use them by default with the following commands: expr, grep, sed. The expr I presented in a previous article, while the rest will be covered in this and the next article.

    If you want to use the extended version, you can do so with the egrep command or the sed -r option and the grep -E option. The awk programming language, which will be the subject of a future article, also uses the extended regular expression. Today I will only cover the extended version. However, if you are interested, there are a couple of articles about the other ones also here on the network. Just search for them!

    More Server Administration Articles
    More By Gabor Bernat


     

    SERVER ADMINISTRATION ARTICLES

    - Processes in the UNIX Shell
    - Migrating from Windows to Wine
    - Wine: Not Another Emulator
    - Preventive Measures to Block SSH Attacks
    - Monitoring Temperatures with Cacti
    - Cacti: RRDTool-based Graphing Solution
    - Network Magic 5.0 Review
    - Netfilter and Iptables Overview
    - Installing and Configuring Squid
    - Clickfree PC Backup Systems Compared
    - Squid, the Caching Proxy
    - Regular Expressions in the Unix Shell
    - Source Code Version Control Solutions
    - OTRS: Open Source Ticket Request System
    - Clonezilla: Free Mass Disk-Cloning Utility





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek