That is sick stuff vgersh99...unfortunately i forgot to tell you that my input.txt is a lot longer than 3 lines, say it's 6 lines, but I still don't want to overwrite the HHH.
Code:
$ cat input.txt
RRR
SSS
TTT
UUU
VVV
but I still want the "HHH". So this is more like a INSERT and not a overwrite. My bad.
---------- Post updated at 04:25 PM ---------- Previous update was at 03:58 PM ----------
hey guys, actually i found a suggestion that solves one of my two problems.
Code:
Make a file, say my.sed, that contains:
s/^%%Page:.*/&\
added line 1\
added line 2\
added line 3\
added line 4/
Add more lines as needed. Then:
sed -f my.sed < infile.ps > outfile.ps
-Rouben Rostamian
I think my question is set. Thanks for looking everyone! Thanks vgersh99 for the sick one liner.
there's no limitation/hard-wiring on the number of lines to be inserted - everythig is driven by the content in your input.txt file. It should work for ANY number of lines.
I have a file which contains blocks of text - each block is a multi-lines text delimited by blank lines eg.
<blank line>
several lines of text
...
pattern found on this line
several more lines of text
...
<blank line>
How do you delete the block of text (including the blank lines) when... (17 Replies)
Hi, I've been searching in this forum for the last 4 hours trying to do one thing: search 2 lines and delete the above line. So far I have not be able to find something similar in this forum, so I need help. This is what I'm trying to do. For example, I have a file called file1:
file1
word1... (4 Replies)
I have sql's in a file separated by ";", need to put the sql in one single line till i find a ";" The input file is like this
SELECT s.sid,
s.serial#,
p.spid as "OS PID",
s.username,
s.module,
... (6 Replies)
Hi Experts,
i am beginner in perl and need your help to find a solution.. I have a block of multiple lines like below say module 1 to module 100
***** MAKING > module1 **************
kvmfkvmmfdv
svksmnvlksmfvks dcsdvcs
sddvcsv ssvsdvdf error: abcdefghi
wrw wvsv dsvds sdvsd
error:... (5 Replies)
All I want is to look for the pattern in the file...If I found it at # places... I want print lines after those pattern(line) until I find a blank line.
Log EXAMPLE :
MT:Exception caught
The following Numbers were affected:
1234
2345
2346
Error
java.lang.InternalError:... (3 Replies)
HI group members
I am new in unix
I want to search # symbol in a file.
if found need to delete the entire row in the file.
need to move the actual data(with out # symbol data) to another file.
Thanks (2 Replies)
Hi All,
Am very new for this Shell scripting.
Could anyone pls let me know how to delete a set of lines from a (.DAT) file using ksh script.
for example from line 3 to line 7. The size of the target file is huge:(
---------- Post updated at 11:01 PM ---------- Previous update was at 11:00 PM... (5 Replies)
Hi Everyone!
I would like ask if there's a better way I can delete multiple lines in a file1 by collecting all criteria from file2.
file1:
a
b
c
d
e
f
file2:
a
e
f
The expected value will be:
b (3 Replies)
This is for AIX 6.1, I've a flat file and the format is like this
DECLARE
some statements;
BEGIN
some statements;
END;
I've to search BEGIN and replace it with the following 4 lines
BEGIN
For x in 1..1
LOOP
BEGIN
Similarly I've to search END and replace it with the... (7 Replies)
Hi all,
I'm looking for a way (sed or awk) to delete multiple lines between blank lines containing two patterns ex:
user: alpha
parameter_1 = 15
parameter_2 = 1
parameter_3 = 0
user: alpha
parameter_1 = 15
parameter_2 = 1
parameter_3 = 0
user: alpha
parameter_1 = 16... (3 Replies)
Discussion started by: ce9888
3 Replies
LEARN ABOUT DEBIAN
mail::message::body::construct
Mail::Message::Body::Construct(3pm) User Contributed Perl Documentation Mail::Message::Body::Construct(3pm)NAME
Mail::Message::Body::Construct - adds functionality to Mail::Message::Body
DESCRIPTION
This package adds complex functionality to the Mail::Message::Body class. This functions less often used, so many programs will not
compile this package.
METHODS
Constructing a body
$obj->attach(MESSAGES, OPTIONS)
Make a multipart containing this body and the specified MESSAGES. The options are passed to the constructor of the multi-part body. If
you need more control, create the multi-part body yourself. At least take a look at Mail::Message::Body::Multipart.
The message-parts will be coerced into a Mail::Message::Part, so you may attach Mail::Internet or MIME::Entity objects if you want
--see Mail::Message::coerce(). A new body with attached messages is returned.
example:
my $pgpkey = Mail::Message::Body::File->new(file => 'a.pgp');
my $msg = Mail::Message->buildFromBody(
$message->decoded->attach($pgpkey));
# The last message of the $multi multiparted body becomes a coerced $entity.
my $entity = MIME::Entity->new;
my $multi = $msg->body->attach($entity);
# Now create a new message
my $msg = Mail::Message->new(head => ..., body => $multi);
$obj->concatenate(COMPONENTS)
Concatenate a list of elements into one new body.
Specify a list of text COMPONENTS. Each component can be a message (Mail::Message, the body of the message is used), a plain body
(Mail::Message::Body), "undef" (which will be skipped), a scalar (which is split into lines), or an array of scalars (each providing
one line).
example:
# all arguments are Mail::Message::Body's.
my $sum = $body->concatenate($preamble, $body, $epilogue, "--
" , $sig);
$obj->foreachLine(CODE)
Create a new body by performing an action on each of its lines. If none of the lines change, the current body will be returned,
otherwise a new body is created of the same type as the current.
The CODE refers to a subroutine which is called, where $_ contains body's original line. DO NOT CHANGE $_!!! The result of the
routine is taken as new line. When the routine returns "undef", the line will be skipped.
example:
my $content = $msg->decoded;
my $reply = $content->foreachLine( sub { '> '.$_ } );
my $rev = $content->foreachLine( sub {reverse} );
sub filled() { length $_ > 1 ? $_ : undef }
my $nonempty = $content->foreachLine( &filled );
my $wrong = $content->foreachLine( sub {s/a/A/} ); # WRONG!!!
my $right = $content->foreachLine(
sub {(my $x=$_) =~ s/a/A/; $x} );
$obj->stripSignature(OPTIONS)
Strip the signature from the body. The body must already be decoded otherwise the wrong lines may get stripped. Returned is the
stripped version body, and in list context also the signature, encapsulated in its own body object. The signature separator is the
first line of the returned signature body.
The signature is added by the sender to tell about him- or herself. It is superfluous in some situations, for instance if you want to
create a reply to the person's message you do not need to include that signature.
If the body had no signature, the original body object is returned, and "undef" for the signature body.
-Option --Default
max_lines 10
pattern qr/^--s?$/
result_type <same as current>
max_lines => INTEGER|undef
The maximum number of lines which can be the length of a signature. Specify "undef" to remove the limit.
pattern => REGEX|STRING|CODE
Which pattern defines the line which indicates the separator between the message and the signature. In case of a STRING, this is
matched to the beginning of the line, and REGEX is a full regular expression.
In case of CODE, each line (from last to front) is passed to the specified subroutine as first argument. The subroutine must return
TRUE when the separator is found.
result_type => CLASS
The type of body to be created for the stripped body (and maybe also to contain the stripped signature)
example:
my $start = $message->decoded;
my $start = $body->decoded;
my $stripped = $start->stripSignature;
my ($stripped, $sign) = $start->stripSignature
(max_lines => 5, pattern => '-*-*-');
SEE ALSO
This module is part of Mail-Box distribution version 2.105, built on May 07, 2012. Website: http://perl.overmeer.net/mailbox/
LICENSE
Copyrights 2001-2012 by [Mark Overmeer]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See
http://www.perl.com/perl/misc/Artistic.html
perl v5.14.2 2012-05-07 Mail::Message::Body::Construct(3pm)