sed

From Gentoo Wiki
Jump to:navigation Jump to:search
This article is a stub. Please help out by expanding it - how to get started.

sed (stream editor) is a program that uses regular expressions to programmatically modify streams of text. In meany ways sed is an evolved ed with significantly more advanced scripting capabilities than its predecessor. Where ed sees occasional use as a means to edit individual lines within a file sed is commonly used to transform entire documents. In this capacity sed has historically been second only to Perl — which has the advantage of being a complete programming language it its own right — in its ability to rapidly manipulate large quantities of text with regular expressions. In modern environments that require grapheme-level Unicode support or recursive grammars, Raku occasionally edges-out both sed and Perl for such workloads.

Installation

sed is part of @system and needs no separate installation.

USE flags

USE flags for sys-apps/sed Super-useful stream editor

acl Add support for Access Control Lists
nls Add Native Language Support (using gettext - GNU locale utilities)
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
static !!do not set this during bootstrap!! Causes binaries to be statically linked instead of dynamically
verify-sig Verify upstream signatures on distfiles

Emerge

root #emerge --ask sys-apps/sed

Usage

The article in the devmanual might help.

user $sed --help
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
      --debug
                 annotate program execution
  -e script, --expression=script
                 add the script to the commands to be executed
  -f script-file, --file=script-file
                 add the contents of script-file to the commands to be executed
  --follow-symlinks
                 follow symlinks when processing in place
  -i[SUFFIX], --in-place[=SUFFIX]
                 edit files in place (makes backup if SUFFIX supplied)
  -l N, --line-length=N
                 specify the desired line-wrap length for the `l' command
  --posix
                 disable all GNU extensions.
  -E, -r, --regexp-extended
                 use extended regular expressions in the script
                 (for portability use POSIX -E).
  -s, --separate
                 consider files as separate rather than as a single,
                 continuous long stream.
      --sandbox
                 operate in sandbox mode (disable e/r/w commands).
  -u, --unbuffered
                 load minimal amounts of data from the input files and flush
                 the output buffers more often
  -z, --null-data
                 separate lines by NUL characters
      --help     display this help and exit
      --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-sed@gnu.org>.

Unmerge

root #emerge --ask --depclean --verbose sys-apps/sed

See also

  • ed — a line-based text editor with support for regular expressions
  • grep — a tool for searching text files with regular expressions
  • awk — a scripting language for data extraction
  • Perl — a general purpose interpreted programming language with a powerful regular expression engine.
  • Raku — a high-level, general-purpose, and gradually typed programming language with low boilerplate objects, optionally immutable data structures, and an advanced macro system.

External references