Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Sed
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===sed used as a filter=== Under Unix, sed is often used as a [[filter (Unix)|filter]] in a [[pipeline (Unix)|pipeline]]: <syntaxhighlight lang="console"> $ generateData | sed 's/x/y/g' </syntaxhighlight> That is, a program such as "generateData" generates data, and then sed makes the small change of replacing ''x'' with ''y''. For example: <syntaxhighlight lang="console"> $ echo xyz xyz | sed 's/x/y/g' yyz yyz </syntaxhighlight> <ref group="notes" name="quotes"> In command line use, the quotes around the expression are not required, and are only necessary if the shell would otherwise not interpret the expression as a single word (token). For the script <code>s/x/y/g</code> there is no ambiguity, so <code>generateData | sed s/x/y/g</code> works correctly. However, quotes are usually included for clarity, and are often necessary, notably for whitespace (e.g., <code>'s/x x/y y/'</code>). Most often single quotes are used, to avoid having the shell interpret <code>$</code> as a shell variable. Double quotes are used, such as <code>"s/$1/$2/g"</code>, to allow the shell to substitute for a command line argument or other shell variable. </ref>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Sed
(section)
Add topic