Module 39 ed

Previous Table of Contents Next


Module 39
ed

DESCRIPTION

The external ed command is a line editor. It is the standard text editor for UNIX. A line editor displays a prompt while waiting for you to enter editing commands. It does not display a screen full of text for you to move the cursor around on and make changes. Instead, you display text with an edit command, then use other edit commands to change existing text or add new text.

You may wonder why anyone would still want to learn and use a line editor. There are a couple of reasons. The first is you may need a shell script to manipulate the contents of a file. Your choices are to use ed , nawk , or sed . But remember, ed is the base of the other two, and the benefit of using ed is you read and write in the same file. It takes time to read a file with nawk , redirect the output to another file, then move the file back to the original filename. The other reason for using ed is speed. It is fast compared to a full-screen editor when you need to perform simple known changes to text ” especially on extremely large files.

COMMAND FORMAT

Following is the general format of the ed command.

  ed  [  -p   prompt  ] [  -s  ] [  -x  ] [  -C  ]  file   red  [  -p   prompt  ] [  -s  ] [  -x  ] [  -C  ]  file  

BSD (Berkeley)
ed [ - ] [ -x ] file

Options

The following list describes the options and their arguments that may be used to control how ed functions.

-C Same as -x below except all text read into the buffer is assumed to be encrypted, unless a null key is specified.
-p prompt The -p specifies that a user -defined prompt follows . This allows you to define your own for an internal edit command prompt. For example,
$ ed -p "infile: " infile
infile: _
causes ed to prompt you with infile: instead of the default : ( colon ) prompt.
-s Suppresses the printing of information type messages. Character counts from the e , r , and w commands are suppressed. The diagnostics from the e and q commands are suppressed. The ! prompt displayed after a ! command is also suppressed. On versions prior to SVR4 this was the - option.
-x An encrypted file is to be edited. The file is encrypted when it is saved to disk. It is decrypted when it is read into the editing buffer. You are required to enter an encryption key each time you start editing the file.

NOTE:    
The -x option is part of the Security Administration Utilities. These utilities are only available in the United States.


NOTE:    
The ed editor no longer supports the - option. The - option has been replaced with the -s option. System V only.


BSD (Berkeley)
- Same as System V -s option.
-x Same as System V -x option.

Arguments

The following argument may be passed to the ed command.

file The name of the file you want to edit.

FUNCTIONAL OVERVIEW

ed does not actually edit the specified file . It edits a copy of the file it has read into a temporary work file called a buffer. Thus all the edit commands you perform have no effect on the original file until you write the buffer back to the original file using the w command.


Previous Table of Contents Next

Copyright Wordware Publishing, Inc.


Illustrated UNIX System V
Illustrated Unix System V/Bsd
ISBN: 1556221878
EAN: 2147483647
Year: N/A
Pages: 144
Authors: Robert Felps

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net