replace block of text with content of another file
Hello,
file1: file2: desired output:
What I have so far:
Works all right but I was expecting to come up with something more straight forward, more terse. Also, this sed solution uses two processes. I couldn't get it work in one.
I tried also awk with getline and a redirection from the file2 but to it was also too complicated. I have that strange feeling that there must be some simple solution but couldn't find it.
Hi,
I want to replace _F* by _F in a xml file. what is the sed command.
I have tried sed "s/_F$/_F/g" or sed "s/_F*/_F/g" , but it does not work. thx
file content
<TAG>KC_FOU</TAG>
<TAG>KC_FABC</TAG>
<TAG>KC_FABCDG</TAG>
desire output
<TAG>KC_F</TAG>
<TAG>KC_F</TAG>
<TAG>KC_F</TAG> (6 Replies)
I need to replace (delete) a text block in a bunch of files, its a html table, almost at the end of pages but the location varies.
In Windows I used Filemonkey, but nothing like that in Unix?
There is replace from mysql, but how does it deal with newlines?
sed only works with single lines,... (6 Replies)
Our system is receiving one feed from the third party.
One of the field in the flat file is ID which id from position 19 to 27. In some cases this ID is coming as 9 zeros (000000000) or 1 right padded zero. ( 0)
For these specific records I want to replace fthis field with blank... (3 Replies)
My apologies if this has been answered in a previous post. I've been doing a lot of searching, but I haven't been able to find what I was looking for. Specifically, I am wondering if I can utilize sed and/or awk to locate two strings in a file, and replace everything between those two strings... (12 Replies)
Hi,
My requirement is to find a text and replace it with another in a XML file.
I am new to Unix,Please provide some suggestion to achieve.
Find:
<Style ss:ID="ColumnHeader1">
Replace with:
<Style ss:ID="ColumnHeader1">
<Borders>
<Border ss:Position="Bottom"... (4 Replies)
Hello everyone,
I work under Ubuntu 11.10 (c-shell)
I need a script to create a new text file whose content is the text of another text files that are in the directory $DIRMAIL at this moment.
I will show you an example:
- On the one hand, there is a directory $DIRMAIL where there are... (1 Reply)
I have a file myfile with only one value 1000.I am using it in a shell script.Each time i run the script,the file shud get incremented by 1. I have used the below code for incrementing the value-
curr=`cat myfile`
echo $curr
curr=`expr $curr + 1`
But i am not sure how to save this replaced... (2 Replies)
Hello,
I'm an starter in Bash scripting. I would like to write a script in Bash shell that replaces a specific text block (a function) by another text block in a file:
for example in my file --> $HOME/myFile.js
replacing following function between other functions in the file:
function ABC()... (6 Replies)
Hi,
I am having trouble while using 'sed' with reading files. Please help. I have 3 files. File A, file B and file C. I want to find content of file B in file A and replace it by content in file C.
Thanks a lot!!
Here is a sample of my question.
e.g. (file A: a.txt; file B: b.txt; file... (3 Replies)
Hi,
I am having a files in my directory like this:
2014 1049_file1.txt
2014 1050_file2.txt
2014 1110_file3.txt
2014 1145_file4.txt
2014 2049_file5.txt
I need to replace the above file names like this without changing the content of filename:
file1.txt
file2.txt
file3.txt... (10 Replies)
Discussion started by: rohit_shinez
10 Replies
LEARN ABOUT DEBIAN
poe::filter::block
POE::Filter::Block(3pm) User Contributed Perl Documentation POE::Filter::Block(3pm)NAME
POE::Filter::Block - translate data between streams and blocks
SYNOPSIS
#!perl
use warnings;
use strict;
use POE::Filter::Block;
my $filter = POE::Filter::Block->new( BlockSize => 8 );
# Prints three lines: abcdefgh, ijklmnop, qrstuvwx.
# Bytes "y" and "z" remain in the buffer and await completion of the
# next 8-byte block.
$filter->get_one_start([ "abcdefghijklmnopqrstuvwxyz" ]);
while(1) {
my $block = $filter->get_one();
last unless @$block;
print $block->[0], "
";
}
# Print one line: yz123456
$filter->get_one_start([ "123456" ]);
while(1) {
my $block = $filter->get_one();
last unless @$block;
print $block->[0], "
";
}
DESCRIPTION
POE::Filter::Block translates data between serial streams and blocks. It can handle fixed-length and length-prepended blocks, and it may
be extended to handle other block types.
Fixed-length blocks are used when Block's constructor is called with a BlockSize value. Otherwise the Block filter uses length-prepended
blocks.
Users who specify block sizes less than one deserve what they get.
In variable-length mode, a LengthCodec parameter may be specified. The LengthCodec value should be a reference to a list of two functions:
the length encoder, and the length decoder:
LengthCodec => [ &encoder, &decoder ]
The encoder takes a reference to a buffer and prepends the buffer's length to it. The default encoder prepends the ASCII representation of
the buffer's length and a chr(0) byte to separate the length from the actual data:
sub _default_encoder {
my $stuff = shift;
substr($$stuff, 0, 0) = length($$stuff) . "