Se o seu sistema possui a versão GNU de sed
, você pode usar o comando r
da extensão GNU:
r filename
As a GNU extension, this command accepts two addresses.
Queue the contents of filename to be read and inserted into the
output stream at the end of the current cycle, or when the next input
line is read. Note that if filename cannot be read, it is treated as
if it were an empty file, without any error indication.
As a GNU sed extension, the special value /dev/stdin is supported for
the file name, which reads the contents of the standard input.
Por exemplo,
$ sed '3r /dev/stdin' 123.txt < <(sed -n '2,4p' abc.txt)
1
2
3
b
c
d
4
5