Discussion:
sed r option | insert file
Thierry Blanc Thierry.Blanc@gmx.ch [sed-users]
2016-12-18 22:02:29 UTC
Permalink
I try to insert a textblock saved in a file (file1.txt) into another
file (file2.txt). File 2 is an rdf file.

file 1 should be inserted into a block and replace the content of the block.

sed -r '
/<RDF:Seq RDF:about="urn:scrapbook:item20161219002711">/,/<\/RDF:Seq>/{

r file1.txt

}' file2.txt

The strange thing is that is only inserts 114 lines, then the block end
appears. After that the same 114 are lines are printed again.

I am not on drugs ...
???






[Non-text portions of this message have been removed]
sharma__r@hotmail.com [sed-users]
2016-12-19 15:15:12 UTC
Permalink
sed ' /start/,/stop/r file.txt '
1. the above will execute the "r" command foreach line in the block including
the boundaries.
2. first the pattern space is printed then the "r" file is scheduled for flush; unless interrupted by the N/n or -n option.
3. default action is print pattern space, all the lines of block are printed and after each of these lines the "r" file.txt would be printed as well.
The strange thing is that is only inserts 114 lines, then the block end
appears. After that the same 114 are lines are printed again.
I am not on drugs ...
---In sed-***@yahoogroups.com, <***@...> wrote :

I try to insert a textblock saved in a file (file1.txt) into another
file (file2.txt). File 2 is an rdf file.

file 1 should be inserted into a block and replace the content of the block.

sed -r '
/<RDF:Seq RDF:about="urn:scrapbook:item20161219002711">/,/<\/RDF:Seq>/{

r file1.txt

}' file2.txt

The strange thing is that is only inserts 114 lines, then the block end
appears. After that the same 114 are lines are printed again.

I am not on drugs ...
???






[Non-text portions of this message have been removed]



[Non-text portions of this message have been removed]
sharma__r@hotmail.com [sed-users]
2016-12-19 15:05:06 UTC
Permalink
sed -ne '
/BEGIN/{
p; r file.txt
:loop
$q; n
/END/!bloop
}
p
' < yourfile




[Non-text portions of this message have been removed]

Loading...