I can't seem to find exactly what I'm looking for, and haven't had any luck patching things together.
I need to look through a file, and if the record length is not 874, then add 'E' in position 778.
Your help is greatly appreciated.
Here's one way to do it with Perl:
Here's a demonstration of this script with 8 in place of 874 and 6 in place of 778, i.e. for the problem "if the record length is not 8, then add 'E' in position 6":
HTH,
tyler_durden
* Not sure what your data file looks like, but here's a more robust variation of the script:
Last edited by durden_tyler; 11-05-2009 at 01:46 PM..
Very, very new to unix scripting and have a unique situation. I have a file of records that contain 3 records types:
(H)eader Records
(D)etail Records
(T)railer Records
The Detail records are 82 bytes in length which is perfect. The Header and Trailer records sometimes are 82 bytes in... (3 Replies)
I am new to awk and writing a script using awk. I have file containing fixed length records, I wish to extract 2 substring(each substring is padded with zeros on left e.g 000000003623) and add each substring respectively for every record in the file to get total sum of respective substring for all... (5 Replies)
Hi,
The record length may be differ in afile. I want to display the records if the record length is not equal to 50 using sed/awk command.
Thanks in Advance (6 Replies)
When I check the length for the records in the file, it does not give me the correct value. I used wc -l command.
Example records:
abcdefghij
abcd\efghij
abcdefghi
Expected output is:
10
11
9
But the output returned is
10
10
9
Please help me on this issue. (10 Replies)
Hi,
I need help with one problem, I came across recently.
I have one input file which I need to delimit based on character length.
$ cat Input.txt
12345sda231453
asd760kjol62569
sdasw4g76gdf57
And, There is one comma separated file which mentions "start of the field" and "length... (6 Replies)
I want to do FTP an Huge XML file to mainframe server using AIX server
Since my file size is huge, i want to split the XML file based on a delimiter , the record delimiter should be set after every 27000 bytes of data
and then do the ftp
This is done becos the data send to the mainframe must... (1 Reply)
Good day, I am a newbie here and thanks for accepting me
I have a task to modify input data where my input data looks like
123|34567|CHINE
1|23|INDIA
34512|21|USA
104|901|INDIASee that my input has two columns with different character length but max length is 5 and minimum length is 0 which... (1 Reply)
Hi Team,
I have an issue to split the file which is having special chracter(German Char) using awk command.
I have a different length records in a file. I am separating the files based on the length using awk command.
The command is working fine if the record is not having any... (7 Replies)
Discussion started by: Anthuvan
7 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) . "