Server Administration

  Home arrow Server Administration arrow Page 2 - Stream Editor in the UNIX Shell
SERVER ADMINISTRATION

Stream Editor in the UNIX Shell
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-11-25

    Table of Contents:
  • Stream Editor in the UNIX Shell
  • How does it work?
  • Sed Addresses
  • Sed Commands
  • The hold space and whole scripts

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Stream Editor in the UNIX Shell - How does it work?


    (Page 2 of 5 )

    The concept is simple. Cut it into small pieces. Execute the commands for each piece. Do this until finished. However, let us expand on this a little. First, the command reads in the text. Next follows the tokenization. The sed will search for the first new line character from the text. Take out this segment. Cut down the newline character. Insert it into the pattern space.

    Inside the sed, there exists two buffers. The first is the pattern space while the second is the hold space. Once a new pattern is present in the first one, the sed will start to run the commands given as argument. At every command, first a check is going to be issued to see whether or not its address matches the current one.

    The sed commands are very descriptive. You will form them as delete the first line, print the second or print the lines that match this regular expression. You can even replace part of the text and print forward the new one with the help of a few simple instructions.

    If done with the command list, and we did not request to skip this step with the -n option attribute (or to use the hold space), it will print the text on the output. It will also add a newline character as compensation for the one deleted before putting it into the pattern space.

    If we did not give any special commands to request this step, it will also delete the pattern space. In the next moments, it will take the text again, search for the next new line, and take it all over from the start again. The goal of the hold space is to put it there before the deletion of the pattern space lines occurs. This way we can call them back later on when we need them. It is a sort of "save line for later" option.

    More Server Administration Articles
    More By Gabor Bernat

    blog comments powered by Disqus

    SERVER ADMINISTRATION ARTICLES

    - Server Responses to Client Communication
    - Authentication in Client/Server Communication
    - Client/Server Communication
    - Understanding Awk in the UNIX Shell
    - Stream Editor in the UNIX Shell
    - 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


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