Java
This commit is contained in:
237
APL1.2/SCR1.2/TP12/de commandes avec sed :
Normal file
237
APL1.2/SCR1.2/TP12/de commandes avec sed :
Normal file
@@ -0,0 +1,237 @@
|
||||
SED(1) User Commands SED(1)
|
||||
|
||||
NNAAMMEE
|
||||
sed - stream editor for filtering and transforming text
|
||||
|
||||
SSYYNNOOPPSSIISS
|
||||
sseedd [_O_P_T_I_O_N]... _{_s_c_r_i_p_t_-_o_n_l_y_-_i_f_-_n_o_-_o_t_h_e_r_-_s_c_r_i_p_t_} [_i_n_p_u_t_-_f_i_l_e]...
|
||||
|
||||
DDEESSCCRRIIPPTTIIOONN
|
||||
_S_e_d 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 sim‐
|
||||
ilar to an editor which permits scripted edits (such as _e_d), _s_e_d works by making only one pass over the input(s), and is consequently more efficient. But it is
|
||||
_s_e_d's ability to filter text in a pipeline which particularly distinguishes it from other types of editors.
|
||||
|
||||
--nn, ----qquuiieett, ----ssiilleenntt
|
||||
|
||||
suppress automatic printing of pattern space
|
||||
|
||||
----ddeebbuugg
|
||||
|
||||
annotate program execution
|
||||
|
||||
--ee script, ----eexxpprreessssiioonn=_s_c_r_i_p_t
|
||||
|
||||
add the script to the commands to be executed
|
||||
|
||||
--ff script-file, ----ffiillee=_s_c_r_i_p_t_-_f_i_l_e
|
||||
|
||||
add the contents of script-file to the commands to be executed
|
||||
|
||||
----ffoollllooww--ssyymmlliinnkkss
|
||||
|
||||
follow symlinks when processing in place
|
||||
|
||||
--ii[[SSUUFFFFIIXX]], ----iinn--ppllaaccee[=_S_U_F_F_I_X]
|
||||
|
||||
edit files in place (makes backup if SUFFIX supplied)
|
||||
|
||||
--ll N, ----lliinnee--lleennggtthh=_N
|
||||
|
||||
specify the desired line-wrap length for the `l' command
|
||||
|
||||
----ppoossiixx
|
||||
|
||||
disable all GNU extensions.
|
||||
|
||||
--EE, --rr, ----rreeggeexxpp--eexxtteennddeedd
|
||||
|
||||
use extended regular expressions in the script (for portability use POSIX --EE).
|
||||
|
||||
--ss, ----sseeppaarraattee
|
||||
|
||||
consider files as separate rather than as a single, continuous long stream.
|
||||
|
||||
----ssaannddbbooxx
|
||||
|
||||
operate in sandbox mode (disable e/r/w commands).
|
||||
|
||||
--uu, ----uunnbbuuffffeerreedd
|
||||
|
||||
load minimal amounts of data from the input files and flush the output buffers more often
|
||||
|
||||
--zz, ----nnuullll--ddaattaa
|
||||
|
||||
separate lines by NUL characters
|
||||
|
||||
----hheellpp
|
||||
display this help and exit
|
||||
|
||||
----vveerrssiioonn
|
||||
output version information and exit
|
||||
|
||||
If no --ee, ----eexxpprreessssiioonn, --ff, or ----ffiillee 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>.
|
||||
|
||||
CCOOMMMMAANNDD SSYYNNOOPPSSIISS
|
||||
This is just a brief synopsis of _s_e_d commands to serve as a reminder to those who already know _s_e_d; other documentation (such as the texinfo document) must be con‐
|
||||
sulted for fuller descriptions.
|
||||
|
||||
ZZeerroo--aaddddrreessss ````ccoommmmaannddss''''
|
||||
: _l_a_b_e_l
|
||||
Label for bb and tt commands.
|
||||
|
||||
#_c_o_m_m_e_n_t
|
||||
The comment extends until the next newline (or the end of a --ee script fragment).
|
||||
|
||||
} The closing bracket of a { } block.
|
||||
|
||||
ZZeerroo-- oorr OOnnee-- aaddddrreessss ccoommmmaannddss
|
||||
= Print the current line number.
|
||||
|
||||
a \
|
||||
|
||||
_t_e_x_t Append _t_e_x_t, which has each embedded newline preceded by a backslash.
|
||||
|
||||
i \
|
||||
|
||||
_t_e_x_t Insert _t_e_x_t, which has each embedded newline preceded by a backslash.
|
||||
|
||||
q [_e_x_i_t_-_c_o_d_e]
|
||||
Immediately quit the _s_e_d script without processing any more input, except that if auto-print is not disabled the current pattern space will be printed. The
|
||||
exit code argument is a GNU extension.
|
||||
|
||||
Q [_e_x_i_t_-_c_o_d_e]
|
||||
Immediately quit the _s_e_d script without processing any more input. This is a GNU extension.
|
||||
|
||||
r _f_i_l_e_n_a_m_e
|
||||
Append text read from _f_i_l_e_n_a_m_e.
|
||||
|
||||
R _f_i_l_e_n_a_m_e
|
||||
Append a line read from _f_i_l_e_n_a_m_e. Each invocation of the command reads a line from the file. This is a GNU extension.
|
||||
|
||||
CCoommmmaannddss wwhhiicchh aacccceepptt aaddddrreessss rraannggeess
|
||||
{ Begin a block of commands (end with a }).
|
||||
|
||||
b _l_a_b_e_l
|
||||
Branch to _l_a_b_e_l; if _l_a_b_e_l is omitted, branch to end of script.
|
||||
|
||||
c \
|
||||
|
||||
_t_e_x_t Replace the selected lines with _t_e_x_t, which has each embedded newline preceded by a backslash.
|
||||
|
||||
d Delete pattern space. Start next cycle.
|
||||
|
||||
D If pattern space contains no newline, start a normal new cycle as if the d command was issued. Otherwise, delete text in the pattern space up to the first
|
||||
newline, and restart cycle with the resultant pattern space, without reading a new line of input.
|
||||
|
||||
h H Copy/append pattern space to hold space.
|
||||
|
||||
g G Copy/append hold space to pattern space.
|
||||
|
||||
l List out the current line in a ``visually unambiguous'' form.
|
||||
|
||||
l _w_i_d_t_h
|
||||
List out the current line in a ``visually unambiguous'' form, breaking it at _w_i_d_t_h characters. This is a GNU extension.
|
||||
|
||||
n N Read/append the next line of input into the pattern space.
|
||||
|
||||
p Print the current pattern space.
|
||||
|
||||
P Print up to the first embedded newline of the current pattern space.
|
||||
|
||||
s/_r_e_g_e_x_p/_r_e_p_l_a_c_e_m_e_n_t/
|
||||
Attempt to match _r_e_g_e_x_p against the pattern space. If successful, replace that portion matched with _r_e_p_l_a_c_e_m_e_n_t. The _r_e_p_l_a_c_e_m_e_n_t may contain the special
|
||||
character && to refer to that portion of the pattern space which matched, and the special escapes \1 through \9 to refer to the corresponding matching sub-ex‐
|
||||
pressions in the _r_e_g_e_x_p.
|
||||
|
||||
t _l_a_b_e_l
|
||||
If a s/// has done a successful substitution since the last input line was read and since the last t or T command, then branch to _l_a_b_e_l; if _l_a_b_e_l is omitted,
|
||||
branch to end of script.
|
||||
|
||||
T _l_a_b_e_l
|
||||
If no s/// has done a successful substitution since the last input line was read and since the last t or T command, then branch to _l_a_b_e_l; if _l_a_b_e_l is omitted,
|
||||
branch to end of script. This is a GNU extension.
|
||||
|
||||
w _f_i_l_e_n_a_m_e
|
||||
Write the current pattern space to _f_i_l_e_n_a_m_e.
|
||||
|
||||
W _f_i_l_e_n_a_m_e
|
||||
Write the first line of the current pattern space to _f_i_l_e_n_a_m_e. This is a GNU extension.
|
||||
|
||||
x Exchange the contents of the hold and pattern spaces.
|
||||
|
||||
y/_s_o_u_r_c_e/_d_e_s_t/
|
||||
Transliterate the characters in the pattern space which appear in _s_o_u_r_c_e to the corresponding character in _d_e_s_t.
|
||||
|
||||
AAddddrreesssseess
|
||||
_S_e_d commands can be given with no addresses, in which case the command will be executed for all input lines; with one address, in which case the command will only be
|
||||
executed for input lines which match that address; or with two addresses, in which case the command will be executed for all input lines which match the inclusive
|
||||
range of lines starting from the first address and continuing to the second address. Three things to note about address ranges: the syntax is _a_d_d_r_1,_a_d_d_r_2 (i.e., the
|
||||
addresses are separated by a comma); the line which _a_d_d_r_1 matched will always be accepted, even if _a_d_d_r_2 selects an earlier line; and if _a_d_d_r_2 is a _r_e_g_e_x_p, it will
|
||||
not be tested against the line that _a_d_d_r_1 matched.
|
||||
|
||||
After the address (or address-range), and before the command, a !! may be inserted, which specifies that the command shall only be executed if the address (or ad‐
|
||||
dress-range) does nnoott match.
|
||||
|
||||
The following address types are supported:
|
||||
|
||||
_n_u_m_b_e_r Match only the specified line _n_u_m_b_e_r (which increments cumulatively across files, unless the --ss option is specified on the command line).
|
||||
|
||||
_f_i_r_s_t~_s_t_e_p
|
||||
Match every _s_t_e_p'th line starting with line _f_i_r_s_t. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address
|
||||
2~5 will match every fifth line, starting with the second. _f_i_r_s_t can be zero; in this case, _s_e_d operates as if it were equal to _s_t_e_p. (This is an exten‐
|
||||
sion.)
|
||||
|
||||
$ Match the last line.
|
||||
|
||||
/_r_e_g_e_x_p/
|
||||
Match lines matching the regular expression _r_e_g_e_x_p. Matching is performed on the current pattern space, which can be modified with commands such as ``s///''.
|
||||
|
||||
\cc_r_e_g_e_x_pcc
|
||||
Match lines matching the regular expression _r_e_g_e_x_p. The cc may be any character.
|
||||
|
||||
GNU _s_e_d also supports some special 2-address forms:
|
||||
|
||||
0,_a_d_d_r_2
|
||||
Start out in "matched first address" state, until _a_d_d_r_2 is found. This is similar to 1,_a_d_d_r_2, except that if _a_d_d_r_2 matches the very first line of input the
|
||||
0,_a_d_d_r_2 form will be at the end of its range, whereas the 1,_a_d_d_r_2 form will still be at the beginning of its range. This works only when _a_d_d_r_2 is a regular
|
||||
expression.
|
||||
|
||||
_a_d_d_r_1,+_N
|
||||
Will match _a_d_d_r_1 and the _N lines following _a_d_d_r_1.
|
||||
|
||||
_a_d_d_r_1,~_N
|
||||
Will match _a_d_d_r_1 and the lines following _a_d_d_r_1 until the next line whose input line number is a multiple of _N.
|
||||
|
||||
RREEGGUULLAARR EEXXPPRREESSSSIIOONNSS
|
||||
POSIX.2 BREs _s_h_o_u_l_d be supported, but they aren't completely because of performance problems. The \\nn sequence in a regular expression matches the newline character,
|
||||
and similarly for \\aa, \\tt, and other sequences. The _-_E option switches to using extended regular expressions instead; it has been supported for years by GNU sed, and
|
||||
is now included in POSIX.
|
||||
|
||||
BBUUGGSS
|
||||
E-mail bug reports to bbuugg--sseedd@@ggnnuu..oorrgg. Also, please include the output of ``sed --version'' in the body of your report if at all possible.
|
||||
|
||||
AAUUTTHHOORR
|
||||
Written by Jay Fenlason, Tom Lord, Ken Pizzini, Paolo Bonzini, Jim Meyering, and Assaf Gordon.
|
||||
|
||||
This sed program was built with SELinux support. SELinux is enabled on this system.
|
||||
|
||||
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>.
|
||||
|
||||
CCOOPPYYRRIIGGHHTT
|
||||
Copyright © 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
|
||||
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
|
||||
|
||||
SSEEEE AALLSSOO
|
||||
aawwkk(1), eedd(1), ggrreepp(1), ttrr(1), ppeerrllrree(1), sed.info, any of various books on _s_e_d, the _s_e_d FAQ (http://sed.sf.net/grabbag/tutorials/sedfaq.txt),
|
||||
http://sed.sf.net/grabbag/.
|
||||
|
||||
The full documentation for sseedd is maintained as a Texinfo manual. If the iinnffoo and sseedd programs are properly installed at your site, the command
|
||||
|
||||
iinnffoo sseedd
|
||||
|
||||
should give you access to the complete manual.
|
||||
|
||||
sed 4.8 January 2020 SED(1)
|
Reference in New Issue
Block a user