red man page on HP-UX

Man page or keyword search:  
man Server   10987 pages
apropos Keyword Search (all sections)
Output format
HP-UX logo
[printable version]

ed(1)									 ed(1)

NAME
       ed, red - line-oriented text editor

SYNOPSIS
       string] [file]

       string] [file]

DESCRIPTION
       The  command executes a line-oriented text editor.  It is most commonly
       used in scripts and noninteractive editing applications	because,  even
       though it can be used interactively, other editors such as and are typ‐
       ically easier to use in an interactive environment.

       If file is specified, performs an command  (see	below)	on  the	 named
       file;  that  is	to say, the file is read into buffer so that it can be
       edited.

   Options
       The following options are recognized:

	      Use	  string as the prompt string when  in	command	 mode.
			  By default, there is no prompt string.

	      Suppress printing of byte counts by
			  and  commands,  and suppress the prompt after a com‐
			  mand.	 The option is obsolescent and will be removed
			  in a future release.

	      Perform an  command first to handle an encrypted file.

   File Handling
       operates	 on a copy of the file it is editing; changes made to the copy
       have no effect on the original file until a (write) command  is	given.
       The  copy  of  the text being edited resides in a temporary file called
       the buffer.  There is only one buffer.

       is a restricted version of that only allows editing  of	files  in  the
       current	directory  and prohibits executing shell commands via Attempts
       to bypass these restrictions result in the error message

       Both and support the fspec(4) formatting capability.  After including a
       format  specification  as  the first line of file and invoking with the
       controlling terminal in or mode (see stty(1)), the specified tab	 stops
       are  automatically  used when scanning file.  For example, if the first
       line of a file contained

       the tab stops would be set at columns 5, 10, and 15, and a maximum line
       length of 72 would be imposed.

       When  you input text, expands tab characters as they are typed to every
       eighth column as a default.

   Editor Commands Structure
       Commands to have a simple and regular  structure:  zero,	 one,  or  two
       addresses  followed by a single-character command, possibly followed by
       parameters to that command.  These addresses specify one or more	 lines
       in  the	buffer.	  Every	 command  that	requires addresses has default
       addresses, so that the addresses can very often be omitted.

       In general, only one command is allowed on a line.  Append, change, and
       insert commands accept text input which is then placed in the buffer as
       appropriate.  While is accepting text following an append,  change,  or
       insert  command,	 it is said to be in input mode.  While in input mode,
       no editor commands are recognized; all input is merely  collected.   To
       terminate input mode, type a period alone at the beginning of a line.

   Regular Expressions
       supports the Basic Regular Expression (RE) syntax (see regexp(5)), with
       the following additions:

	      ·	 The null RE (for  example,  is	 equivalent  to	 the  last  RE
		 encountered.

	      ·	 If  the closing delimiter of an RE or of a replacement string
		 (for example, would be the last character before  a  newline,
		 that  delimiter  can  be omitted, in which case the addressed
		 line is printed.  The following pairs of commands are equiva‐
		 lent:

		      s/s1/s2		  g/s1		   ?s1
		      s/s1/s2/p		  g/s1/p	   ?s1?

   Line Addresses
       To understand line addressing, remember that maintains a pointer to the
       current line.  Generally speaking, the current line is  the  last  line
       affected by a command.  The exact effect of a given command on the cur‐
       rent  line  is  discussed  under	 the  description  of  each   command.
       Addresses are interpreted according to the following rules:

	      1.  The character refers to the current line.

	      2.  The character refers to the last line of the buffer.

	      3.  A decimal number n refers to the nth line of the buffer.

	      4.  A  refers to the line marked with the mark name character x,
		  which must be a lower-case letter.  Lines  are  marked  with
		  the command described below.

	      5.  An  RE enclosed by slashes () refers to the first line found
		  by searching forward from the	 line  following  the  current
		  line	toward the end of the buffer and stopping at the first
		  line containing a string matching the RE.  If necessary, the
		  search  wraps around to the beginning of the buffer and con‐
		  tinues up to and including the current  line,	 so  that  the
		  entire buffer is searched.  (Also see below.)

	      6.  An RE enclosed by question marks () addresses the first line
		  found by searching backward from the line preceding the cur‐
		  rent line toward the beginning of the buffer and stopping at
		  the first line containing a string matching the RE.  If nec‐
		  essary, the search wraps around to the end of the buffer and
		  continues up to and including the current line.   (Also  see
		  below.)

	      7.  An  address  followed	 by a plus or minus sign followed by a
		  decimal number specifies that	 address  plus	or  minus  the
		  indicated number of lines.  The plus sign can be omitted.

	      8.  If  an address begins with or the addition or subtraction is
		  calculated with respect to the current line.	 For  example,
		  is interpreted as

	      9.  If  an address ends with or 1 is added to or subtracted from
		  the address, respectively.  As a  consequence	 of  this  and
		  rule	8  above, the address refers to the line preceding the
		  current line.	 (To maintain compatibility with earlier  ver‐
		  sions	 of  the  editor,  the	circumflex  and characters are
		  interpreted  identically  when  encountered  in  addresses.)
		  Moreover, multiple trailing and characters have a cumulative
		  effect, so refers to the second line preceding  the  current
		  line.

	      10. For convenience, a comma represents the address pair while a
		  semicolon represents the pair Additionally,  represents  the
		  address pair while represents the pair

       Commands require zero, one, or two addresses.  Commands that do not use
       addresses treat the presence of an address as an error.	Commands  that
       accept one or two addresses assume default addresses when the number of
       addresses specified is insufficient.  If more addresses	are  specified
       than  a	given command requires, the last one or two are used as appro‐
       priate.

       Addresses are usually separated from each other by  a  comma  They  can
       also  be separated by a semicolon in which case the current line is set
       to the first address, after which the  second  address  is  calculated.
       This feature can be used to determine the starting line for forward and
       backward searches (see rules 5 and 6 above).  The second address of any
       two-address  sequence must correspond to a line in the buffer that fol‐
       lows the line corresponding to the first address.

   Editor Commands
       In the following list of commands, the default addresses are  shown  in
       parentheses  (parentheses are not part of the address and should not be
       placed in an actual command except for other purposes).

       It is generally illegal for more than one command to appear on a	 line.
       However, any command (except or can be suffixed by or in which case the
       current line is respectively either listed, numbered,  or  printed,  as
       discussed below under the and commands.

       text
       The	      (append)	command reads text and appends it after
		      the addressed line.   Upon  completion,  the  new
		      current line is the last inserted line, or, if no
		      text was added, at the addressed line.  Address 0
		      is  legal	 for this command, causing the appended
		      text to be placed at the beginning of the buffer.

       text
       The	      (change)	command	 deletes  the  addressed
		      lines  then  accepts input text to replace
		      the deleted lines.  Upon	completion,  the
		      new  current line is the last line in text
		      or, if no text was provided, at the  first
		      line  after  the	deleted	 line  or lines.
		      Address 0 would be interpreted as	 address
		      1.

       The	      (delete)	command	 deletes  the  addressed
		      lines from the buffer.   Upon  completion,
		      the  new	current	 line  is the first line
		      following the deleted text,  or  the  last
		      line  in	the  file if the deleted line or
		      lines were at the end of the buffer.

       The	      (edit) command deletes the entire contents
		      of  the  buffer,	then  reads in the named
		      file.  Upon completion,  the  new	 current
		      line  is	the last line in the buffer.  If
		      no file name is given, the remembered file
		      name,  if	 any, is used (see the command).
		      The number  of  characters  read	is  dis‐
		      played,  and file is remembered for possi‐
		      ble use as a default file name  in  subse‐
		      quent or commands.

		      If  the  file name starts with the rest of
		      the line is interpreted as a shell command
		      whose standard output is to be read.  Such
		      a shell command is not remembered	 as  the
		      current file name.

		      Also see below.

       The	      (forced  edit)  command  is  identical  to
		      except that no check  is	made  to  ensure
		      that  the	 current  buffer  has  not  been
		      altered since the last command.

       If	      file is specified, the (file name) command
		      changes  the remembered file name to file.
		      Otherwise, it prints the	remembered  file
		      name.

       The	      (global)	command	 first	marks every line
		      that matches  the	 given	RE.   Then,  for
		      every such line, the given command-list is
		      executed with the current	 line  initially
		      set to that line.	 A single command or the
		      first of a list of commands appears on the
		      same  line  as  the  global  command.  All
		      lines of a multiple-line list  except  the
		      last  line  must	end with a backslash and
		      commands and associated input are	 permit‐
		      ted.   The  that normally terminates input
		      mode can be omitted if  it  would	 be  the
		      last  line  of the command-list.	An empty
		      command-list is equivalent to the command.
		      The  and commands are not permitted in the
		      command-list.  (Also see below.)

       The interactive
		      (Global) command first  marks  every  line
		      that  matches  the  given	 RE.   Then, for
		      every such line, the line is printed, then
		      the  current  line is changed to that line
		      and one command  (other  than  or	 can  be
		      input  and executed.  After executing that
		      command, the next marked line is	printed,
		      and  so on.  A newline character acts as a
		      null command, and an causes the  re-execu‐
		      tion  of	the most recent command executed
		      within the current invocation of Note that
		      the  commands  input as part of the execu‐
		      tion of the command may address and affect
		      any  lines in the buffer.	 The command can
		      be  terminated  by  an  interrupt	  signal
		      (ASCII DEL or BREAK).

       The	      (help) command gives a short error message
		      explaining the reason for the most  recent
		      diagnostic.

       The	      (Help)  command  causes to enter a mode in
		      which error messages are printed	for  all
		      subsequent  diagnostics.	It also explains
		      the previous if there was one.   The  com‐
		      mand  alternately	 turns	this mode on and
		      off.  Initially, it is off.

       text
       The	      (insert) command inserts the  given
		      text  before  the	 addressed  line.
		      Upon completion, the  current  line
		      is  the  last inserted line, or, if
		      there  were  none,  the	addressed
		      line.   This  command  differs from
		      the command only in  the	placement
		      of  the  input  text.  Address 0 is
		      not legal for this command.

		      Under  the  UNIX	2003  environment
		      (see  standards(5)),  the	 (insert)
		      command  interprets  address  0  as
		      address 1.

       The	      (join)   command	joins  contiguous
		      lines by removing	 the  appropriate
		      newline characters.  If exactly one
		      address is given, this command does
		      nothing.

       The	      (mark)  command marks the addressed
		      line with the name x, which must be
		      a	 lower-case  letter.  The address
		      then  addresses  this  line.   Upon
		      completion,  the	new  current line
		      remains unchanged from before.

       The	      (list) command writes the addressed
		      lines  to standard output in a vis‐
		      ually unambiguous form.  Characters
		      listed  in  the following table are
		      written as the corresponding escape
		      sequence.	  Nonprintable characters
		      not in the table are written  as	a
		      three-digit  octal  number  (with a
		      preceding backslash character)  for
		      each  byte  in  the character (most
		      significant byte first).

		      Long  lines  are	folded	with  the
		      point of folding indicated by writ‐
		      ing a backslash character	 followed
		      by a newline.  The end of each line
		      is marked with a An  (ell)  command
		      can  be  appended	 to  any  command
		      other than or The current line num‐
		      ber  is  set  to the address of the
		      last line written.
				     │
	Escape		       ASCII │	Escape			    ASCII
       Sequence	  Represents   Name  │ Sequence	    Represents	    Name
	  \\	  backslash	 \   │	  \r	  carriage return    CR
	  \a	  alert		BEL  │	  \t	  horizontal tab     HT
	  \b	  backspace	BS   │	  \v	  vertical tab	     VT
	  \f	  formfeed	FF   │

       The	      (move)  command	repositions   the
		      addressed	  lines	 after	the  line
		      addressed by a.  Address 0 is legal
		      for  a, causing the addressed lines
		      to be moved to the beginning of the
		      file.   It is an error if address a
		      falls within  the	 range	of  moved
		      lines;  Upon  completion,	 the  new
		      current  line  is	 the  last   line
		      moved.

       The	      (number)	  command    prints   the
		      addressed	 lines,	 preceding   each
		      line  by	its line number and a tab
		      character.   Upon	 completion,  the
		      new  current  line is the last line
		      printed.	 The   command	 can   be
		      appended	to any command other than
		      or

       The	      (print)	 command    prints    the
		      addressed	 lines.	 Upon completion,
		      the new current line  is	the  last
		      line  printed.   The command may be
		      appended to any other command other
		      than  or	For  example, deletes the
		      current line  and	 prints	 the  new
		      current line.

       The	      (prompt)	command	 causes to prompt
		      with an asterisk (or with string if
		      the  option  was	specified  in the
		      command line)  for  all  subsequent
		      commands.	  The command alternately
		      turns this mode on and off.  It  is
		      initially	 on  if	 the  option  was
		      specified;  otherwise,  off.    The
		      current line number is unchanged.

       The	      (quit)  command causes to exit.  No
		      automatic write of a file	 is  done
		      (but see below).

       The editor exits unconditionally without checking
		      for changes in the buffer since the
		      last command.

       The	      (read) command reads the	specified
		      file  into  the  buffer  after  the
		      addressed line.  If no file name is
		      given, the remembered file name, if
		      any, is  used  (see  the	and  com‐
		      mands).	The  remembered file name
		      is not changed unless file  is  the
		      very   first  file  name	mentioned
		      since was invoked.   Address  0  is
		      legal  for  and places the contents
		      of file at  the  beginning  of  the
		      buffer.  If the read is successful,
		      the number of  characters	 read  is
		      displayed.   Upon	 completion,  the
		      new current line is the  last  line
		      read  into the buffer.  If the file
		      name starts with the  rest  of  the
		      line is interpreted as a shell com‐
		      mand whose standard output is to be
		      read.  For example, appends a list‐
		      ing of files in the current  direc‐
		      tory  to	the end of the file being
		      edited.  A  shell	 command  is  not
		      remembered   as  the  current  file
		      name.

       The	      (substitute) command searches  each
		      addressed line for an occurrence of
		      the specified RE.	 In each line  in
		      which   a	  match	  is  found,  all
		      (nonoverlapped) matched strings are
		      replaced	 by  replacement  if  the
		      global	replacement	indicator
		      appears  after the command.  If the
		      global indicator does  not  appear,
		      only  the	 first	occurrence of the
		      matched string is replaced.   If	a
		      number n appears after the command,
		      only  the	 nth  occurrence  of  the
		      matched  string  on  each addressed
		      line is replaced.	 It is	an  error
		      for the substitution to fail on all
		      addressed	 lines.	  Any	character
		      other  than space or newline can be
		      used instead of to delimit  the  RE
		      and  replacement.	 Upon completion,
		      the new current line  is	the  last
		      line   on	  which	  a  substitution
		      occurred.	 (Also see below.)

		      If an ampersand appears in replace‐
		      ment,  it is replaced by the string
		      matching	the  RE	 on  the  current
		      line.   The  special  meaning of in
		      this context can be  suppressed  by
		      preceding it with

		      As  a  more  general  feature,  the
		      characters where n is a digit,  are
		      replaced by the text matched by the
		      nth regular  subexpression  of  the
		      specified	 RE  enclosed between and
		      When  nested  parenthesized  subex‐
		      pressions	 are present, n is deter‐
		      mined by	counting  occurrences  of
		      starting from the left.

		      When  the	 character  is	the  only
		      character	  in   replacement,   the
		      replacement used in the most recent
		      substitute command is used  as  the
		      replacement  in the current substi‐
		      tute command.  The loses	its  spe‐
		      cial   meaning  when  it	is  in	a
		      replacement string containing  more
		      than one character or when preceded
		      by a

		      A line can be split by substituting
		      a	 newline  character into it.  The
		      newline  in  replacement	must   be
		      escaped  by  preceding  it  by Such
		      substitution cannot be done as part
		      of a or command list.

		      The  value of flags is zero or more
		      of:

			   n	  Substitute for the  nth
				  occurrence  only of the
				  RE   found   on    each
				  addressed line.

			   Substitute  for  all	 nonover‐
			   lapped occurrences of the RE
				  on each addressed line.

			   Write to standard  output  the
			   final line
				  in which a substitution
				  was made.  The line  is
				  written  in  the format
				  specified for the  com‐
				  mand.

			   Write  to  standard output the
			   final line
				  in which a substitution
				  was  made.  The line is
				  written in  the  format
				  specified  for the com‐
				  mand.

			   Write to standard  output  the
			   final line
				  in which a substitution
				  was made.  The line  is
				  written  in  the format
				  specified for the  com‐
				  mand.

       Same as	      command,	except that a copy of the
		      addressed	 lines	is  placed  after
		      address  a  (which can be 0).  Upon
		      completion, the new current line is
		      the last line of the copy.

       The	      (undo) command nullifies the effect
		      of the  most  recent  command  that
		      modified	anything  in  the buffer,
		      that is, the most	 recent	 or  com‐
		      mand.  All changes made to the buf‐
		      fer by  a	 or  global  command  are
		      "undone"	as a single change; if no
		      changes were  made  by  the  global
		      command  (such  as with ), the com‐
		      mand has no  effect.   The  current
		      line  number is set to the value it
		      had immediately before the  command
		      started.

       The complement of the global command
		      in that the lines marked during the
		      first step are those that do  match
		      the RE.

       The complement of the interactive global command
		      in that the lines marked during the
		      first step are those that do  match
		      the RE.

       The	      (write)	 command    writes    the
		      addressed	 lines	into  the   named
		      file.   If the file does not exist,
		      it is created with mode 666  (read‐
		      able  and	 writable  by  everyone),
		      unless the current setting dictates
		      otherwise	  (see	 umask(1).    The
		      remembered file name is not changed
		      unless  file is the very first file
		      name encountered since was invoked.
		      If  no  file  name  is  given,  the
		      remembered file name,  if	 any,  is
		      used  (see the and commands).  Upon
		      completion,   the	  current    line
		      address  is unchanged.  If the com‐
		      mand is successful, the  number  of
		      characters written is displayed.

		      If  the  file  name starts with the
		      rest of the line is interpreted  as
		      a	  shell	 command  whose	 standard
		      input is the addressed lines.  Such
		      a	 shell	command is not remembered
		      as the current file name.

       A key string is demanded from the standard input.
		      Subsequent   and	 commands    will
		      encrypt  and  decrypt the text with
		      this key, using  the  algorithm  of
		      crypt(1).	  An explicitly empty key
		      turns off encryption.

       The line number of  the	addressed  line	 is  dis‐
       played.
		      The   current   line   address   is
		      unchanged by this command.

       The remainder of the line after the
		      is sent to the shell to  be  inter‐
		      preted  and  executed as a command.
		      Within the text  of  that	 command,
		      the unescaped character is replaced
		      with the remembered file name.   If
		      a appears as the first character of
		      the shell command, it  is	 replaced
		      with the text of the previous shell
		      command.	Thus,  repeats	the  last
		      shell command.  If any expansion is
		      performed,  the  expanded	 line  is
		      echoed.	Upon completion, the cur‐
		      rent line address is unchanged.

       An address alone on a line  causes  the	addressed
       line to be printed.
		      A	 newline  alone	 is equivalent to
		      This technique is useful for  step‐
		      ping forward through the buffer.

       If  an  interrupt  signal  (ASCII DEL or BREAK) is
       sent, prints a and returns to its command level.

       The following size limitations apply: 256  charac‐
       ters  per  global  command list, 64 characters per
       file name, and 32 MB  characters	 in  the  buffer.
       The  limit  on  the number of lines depends on the
       amount of user memory: each line takes 1 word.

EXTERNAL INFLUENCES
       For information about the UNIX  standard	 environ‐
       ment, see standards(5).

   Environment Variables
       determines  the preferred command-line interpreter
       for use in all commands.	 If this variable is null
       or  not	set,  the  POSIX  shell, is used (see sh-
       posix(1)).

       When set, specifies a directory	to  be	used  for
       temporary files, overriding the default directory,

       provides	 a default value for internationalization
       variables that are unset or null.  If is unset  or
       null,  the default value is "C" (see lang(5)).  If
       any  internationalization  variable  contains   an
       invalid	setting,  all  internationalization vari‐
       ables default to "C".  See environ(5).

       If is set to a nonempty string value, it overrides
       the  values  of all the other internationalization
       variables, including

       determines the interpretation of text  as  single-
       and/or multibyte characters, the classification of
       characters  as  printable,  and	 the   characters
       matched	by character class expressions in regular
       expressions.

       determines the  locale  that  should  be	 used  to
       affect  the format and contents of diagnostic mes‐
       sages written to standard  error	 and  informative
       messages written to standard output.

       determines  the location of message catalogues for
       the processing of

   International Code Set Support
       Single- and multibyte character code sets are sup‐
       ported.

DIAGNOSTICS
	      Command error.
		      Use  or  to get a detailed explana‐
		      tion.

	      Inaccessible file.
		      Use or to get a  detailed	 explana‐
		      tion.

       If  changes have been made in the buffer since the
       last command that wrote the entire  buffer,  warns
       you  if	you attempt to destroy the buffer with an
       or command.  displays  or  then	continues  normal
       editing	unless	you enter a second or command, in
       which case the second command is executed.  The or
       command-line option inhibits this feature.

EXAMPLES
       Make a simple substitution in from a shell script,
       changing the first occurrence of in  any	 line  to
       and save the changes in

       Note  that,  if	a command fails, the editor exits
       immediately.

WARNINGS
       allows a of characters. Attempting to create lines
       longer  than the allowable limit causes to produce
       a error message.

       If a file contains lines longer than the specified
       limit  (eg.,  4096  characters),	 the longer lines
       will be truncated to the	 stated	 maximum  length.
       Saving  the  file will write the truncated version
       over the original file, thus overwriting the orig‐
       inal lines completely.

       A command cannot be subject to a or a command.

       The  command  and the escape from the and commands
       cannot be used if the the editor is invoked from a
       restricted shell (see sh(1)).

       The  sequence  in  a  regular  expression does not
       match a newline character.

       The command does not handle DEL correctly.

       Files encrypted directly with the command with the
       null key cannot be edited (see crypt(1)).

       If  the editor input is coming from a command file
       (e.g., the editor exits at the first failure of	a
       command in the command file.

       When reading a file, discards ASCII NUL characters
       and all characters after the last  newline.   This
       can  cause  unexpected behavior when using regular
       expressions to search for character sequences con‐
       taining NUL characters or text near end-of-file.

AUTHOR
       was developed by HP and OSF.

FILES
       Temporary buffer file where
		      p is the process number.
       Work is saved here if the terminal is hung up.

SEE ALSO
       awk(1),	csh(1), crypt(1), ex(1), grep(1), ksh(1),
       sed(1),	sh(1),	 sh-posix(1),	stty(1),   vi(1),
       fspec(4),  environ(5),  lang(5),	 regexp(5), stan‐
       dards(5).

       The section in

STANDARDS CONFORMANCE
									 ed(1)
[top]

List of man pages available for HP-UX

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net