Assaf Gordon 07c9c74c6b sed: allow '0rFILE' (insert FILE before the first line)
The 'r' command can be used with address zero, effectively prepending
a file to the beginning of the input file, e.g.:
    sed '0rA.TXT' B.TXT > C.TXT
is equivalent to:
    cat A.TXT B.TXT > C.TXT

With "sed -i", this allows safe in-place prepending of files.
A typical example would be adding a license header to multiple source
files:
    sed -i '0rLICENSE' *.c *.h
    find -iname '*.cpp' | xargs sed -i '0rLICENSE'

A current cumbersome alternative is:
    sed -i -e 'x;${p;x};1rA.TXT' -e '1d'  B.TXT

* NEWS: Mention new feature.
* sed/sed.h (struct readcmd): New struct. (struct sed_cmd): Use new
struct instead of a char* for the filename.
* sed/compile.c (compile_program): Expand conditional detecting invalid
usage of "0" address to allow "0r"; Adjust '0r' to '1r' with prepending
(instead of appending).
* sed/execute.c (execute_program): 'r' command: support prepending.
* sed/debug.c (debug_print_function): Use the new 'struct readcmd'.
* testsuite/cmd-0r.sh: New test.
* testsuite/local.mk (TESTS): Add new test.
* doc/sed.texi (Zero Address): New section. (Adding a header to multiple
files): New example section.
2021-08-16 12:34:20 -06:00
2021-07-10 14:46:53 -07:00
2014-11-30 18:59:33 -08:00
2021-07-10 14:46:53 -07:00
2021-07-10 14:46:53 -07:00
2008-04-10 11:14:38 +02:00
2021-07-10 14:46:53 -07:00
2016-08-26 11:54:30 -04:00
2016-08-22 20:57:02 -04:00
2021-07-10 14:46:53 -07:00
2015-05-01 18:09:51 -07:00
2015-05-01 18:09:51 -07:00

This is the GNU implementation of sed, the Unix stream editor.

GNU Sed website: https://www.gnu.org/software/sed/

See the NEWS file for a brief summary and the ChangeLog for
more detailed descriptions of changes.

If you obtained this file as part of a "git clone", then see the
README-hacking file.  If this file came to you as part of a tar archive,
then see the file INSTALL for compilation and installation instructions.

See the file BUGS for instructions about reporting bugs.

See the files AUTHORS and THANKS for a list of authors and other contributors.

After installation run 'sed --help' or 'man sed' for short usage information,
and 'info sed' for the complete manual. The manual is also available on
sed's website.
S
Description
SED (stream editor) - неинтерактивный текстовый редактор командной строки
https://www.gnu.org/software/sed/
Readme GPL-3.0
3 MiB
0 Stars 1 Watchers 0 Forks
Languages
Shell 43%
C 26.4%
Perl 16.5%
sed 7.3%
Makefile 5.2%
Other 1.6%