Sed: Difference between revisions

From Psygen Wiki
Jump to navigation Jump to search
(Created page with "Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). Sed is similar editors that scrip...")
 
No edit summary
Line 1: Line 1:
Sed is a stream editor.  A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline).  Sed is similar editors that script edits, but sed only makes one pass over the input(s), and thus is more efficient.  But it is sed's  ability to filter text in a pipeline which particularly distinguishes it from other types of editors.
Sed is a stream editor.  A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline).  Sed is similar editors that script edits, but sed only makes one pass over the input(s), and thus is more efficient.  But it is sed's  ability to filter text in a pipeline which particularly distinguishes it from other types of editors.
== Commands ==
<code>: label</code>
<code># comment</code>
<code>{....} Block</code>
<code>=</code> print line number
<code>a \</code> Append
<code>b label Branch
<code>c \</code> change
<code>d</code> and <code>D</code> Delete
<code>g</code> and <code>G</code> Get
<code>h</code> and <code>H</code> Hold
<code>i \</code> Insert
<code>l</code> Look
<code>n</code> and <code>N</code> Next
<code>p</code> and <code>P</code> Print
<code>q</code> Quit
<code>r <i>filename</i></code> Read File
<code>s/..../..../</code> Substitute
<code>t label</code> Test
<code>w filename Write Filename
<code>x eXchange
<code>y/..../..../</code> Transform




Line 5: Line 50:


<ol>
<ol>
  <li>[http://man.he.net/?topic=sed&section=all sed man page]</li>
   <li>[http://www.grymoire.com/Unix/Sed.html Grymoire sed tutorial]</li>
   <li>[http://www.grymoire.com/Unix/Sed.html Grymoire sed tutorial]</li>
</ol>
</ol>

Revision as of 16:08, 10 January 2017

Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). Sed is similar editors that script edits, but sed only makes one pass over the input(s), and thus is more efficient. But it is sed's ability to filter text in a pipeline which particularly distinguishes it from other types of editors.


Commands

: label

# comment

{....} Block

= print line number

a \ Append

b label Branch

c \ change

d and D Delete

g and G Get

h and H Hold

i \ Insert

l Look

n and N Next

p and P Print

q Quit

r filename Read File

s/..../..../ Substitute

t label Test

w filename Write Filename

x eXchange

y/..../..../ Transform


References

  1. sed man page
  2. Grymoire sed tutorial