HP-UX Reference (11i v2 04/09) - 1 User Commands N-Z (vol 2)
s
sed(1) sed(1)
(2) w wfile Write. Append the pattern space to wfile.
(2)
x Exchange the contents of the pattern and hold spaces.
(2)
y/string1/string2/
Transform. Replace all occurrences of characters in string1 with the corresponding charac-
ter in string2. The lengths of string1 and string2 must be equal.
(2)
! function
Don’t. Apply the function (or group, if function is
{ ) only to lines not selected by the address
or addresses.
(0)
: label This command does nothing; it bears a label for
b and t commands to branch to.
(1)
= Place the current line number on the standard output as a line.
(2)
{ Execute the following commands through a matching
} only when the pattern space is
selected. The syntax is:
{ cmd1
cmd2
cmd3
.
.
.
}
(0) An empty command is ignored.
(0)
# If a # appears as the first character on the first line of a script file, that entire line is treated
as a comment with one exception: If the character after the # is an n, the default output is
suppressed. The rest of the line after #n is also ignored. A script file must contain at least
one non-comment line.
EXTERNAL INFLUENCES
Environment Variables
LANG provides a default value for the internationalization variables that are unset or null. If
LANG is
unset or null, the default value of "C" (see lang(5)) is used. If any of the internationalization variables
contains an invalid setting,
sed will behave as if all internationalization variables are set to "C". See
environ(5).
LC_ALL If set to a non-empty string value, overrides the values of all the other internationalization vari-
ables.
LC_CTYPE determines the interpretation of text as single and/or multi-byte characters, the classification
of characters as printable, and the characters matched by character class expressions in regular expres-
sions.
LC_MESSAGES determines the locale that should be used to affect the format and contents of diagnostic
messages written to standard error and informative messages written to standard output.
NLSPATH determines the location of message catalogues for the processing of LC_MESSAGES.
International Code Set Support
Single- and multi-byte character code sets are supported.
EXAMPLES
Make a simple substitution in a file from the command line or from a shell script, changing
abc to xyz:
sed ’s/abc/xyz/’ file1 >file1.out
Same as above but use shell or environment variables var1 and var2 in search and replacement
strings:
sed "s/$var1/$var2/" file1 >file1.out
or
sed ’s/’$var1’/’$var2’/’ file1 >file1.out
Multiple substitutions in a single command:
HP-UX 11i Version 2: September 2004 − 3 − Hewlett-Packard Company Section 1−−835