command-definition.sed.html Maven / Gradle / Ivy
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).
While in some ways similar to an editor which permits scripted edits
(such as ed), sed works by making only one pass over the input(s),
and is consequently more efficient. But it is sed's ability to filter
text in a pipeline which particularly distinguishes it from other
types of editors.
Some examples:
input day into sed("s/day/night/") This will output "night"
input "day and night" into sed("s/\\sand\\s/-to-/") This will output "day-to-night"
(Note the use of \s whitespace character).
Java regular expressions are used for searching and replacing. For an
overview of the Java pattern matching, and substitution, please see the
{@link java.util.regex.Pattern} documentation.