Hello,
I am trying to write a formatted report into a file using .ksh script and awk. Here is the command I am trying to run
echo "before awk" ${SRC_SCHEMA}
echo | awk '{printf "%-20s", ${SRC_SCHEMA} }' >>$REPORT_SQL_NAME
I get the following error
before awk ADW
awk: 0602-562 Field $()... (1 Reply)
I am trying to print a line using awk printf command. The problem I am having is that when the string has spaces in between, it only prints the word upto the first space.
For example, if my variable has "Hello World"
The output is only "Hello".
Here is the command I am using
echo $recCtr... (2 Replies)
Hi
awk '/print/ {print }' format.txt
the above code will search for the argument "print" and displays all the lines which contain "print" from format.txt
i want to print the same but with # as teh beginning
For eg:
format.txt contains
cat dog fire current
print the value of 4
print... (2 Replies)
I am trying to print and delete at the same time 0KB files... using following command
a-> find . -type f | xargs ls -l | awk '{ if($5 == 0) {print $0;}}' | xargs rm $0
but am not successful. Can somebody tell me how to do this ... same time I need files to be printed as well deleted later.
... (4 Replies)
Hallo,
i have a file which looks like this:
$1 $2 $3
Student1 55 Pass
55 Pass
35 Fail
Student2 55 Pass
55 Pass
35 Fail
i want that the $1 field... (3 Replies)
Hi
I am relatively new to awk so i am getting confused a lot
I am in need of help ... I am trying to append coloumns to the end of line using AWK
I tried using this command
awk -F "," '{for(s=7;s<=217;s++);$s="0";}1' OFS=, sam_sri_out
It is giving me an output like this...... (1 Reply)
im using awk as a part of my tasks to filter out stuff for reporting details in our storage environment, supposed i filtered out these details (sorry, this might be long.)
bash$ > for x in 1 2; do symdg show floras0-snap$x | awk '{print $3,$4}'; done
: REGULAR
in GNS
Yes
:... (10 Replies)
Hi All
I had requirement where I need to re-order columns in a file by using a control file.
here is the ctrl file
c1
c2
c3
source file
c3 | c1 | c2
a | b| c
I should create output file based on the ctrl file columns
o/p should look like this
c1 | c2 | c3
b| c|a
I wrote some... (9 Replies)
Hello All,
I have the following command which works partially:
gzcat *2016-03-25_*gz | gawk -F"|" '
BEGIN{format = "%-10s %-13s %-17s %-35s\n";
printf format, "EVENT_TYPE","RESPONSE_CODE","INTERNAL_ERR_CODE","FLOWNAME";
printf format, "----------", "-------------", "-----------------",... (6 Replies)
Discussion started by: EAGL€
6 Replies
LEARN ABOUT DEBIAN
mail::mboxparser::mail::body
MboxParser::Mail::Body(3pm) User Contributed Perl Documentation MboxParser::Mail::Body(3pm)NAME
Mail::MboxParser::Mail::Body - rudimentary mail-body object
SYNOPSIS
use Mail::MboxParser;
[...]
# $msg is a Mail::MboxParser::Mail
my $body = $msg->body(0);
# or preferably
my $body = $msg->body($msg->find_body);
for my $line ($body->signature) { print $line, "
" }
for my $url ($body->extract_urls(unique => 1)) {
print $url->{url}, "
";
print $url->{context}, "
";
}
DESCRIPTION
This class represents the body of an email-message. Since emails can have multiple MIME-parts and each of these parts has a body it is not
always easy to say which part actually holds the text of the message (if there is any at all). Mail::MboxParser::Mail::find_body will help
and suggest a part.
METHODS
as_string ([strip_sig => 1])
Returns the textual representation of the body as one string. Decoding takes place when the mailbox has been opened using the decode =>
'BODY' | 'ALL' option.
If 'strip_sig' is set to a true value, the signature is stripped from the string.
as_lines ([strip_sig => 1])
Sames as as_string() just that you get an array of lines with newlines attached to each line.
NOTE: When the body is actually some encoded binary data (most commonly such a body is base64-encoded), you can still use this method.
Then you wont really get proper lines. Instead you get chunks of binary data that you should concatenate as in
my $binary = join "", $body->as_lines;
If 'strip_sig' is set to a true value, the signature is stripped from the string.
signature
Returns the signature of a message as an array of lines. Trailing newlines are already removed.
$body->error returns a string if no signature has been found.
extract_urls
extract_urls (unique => 1)
Returns an array of hash-refs. Each hash-ref has two fields: 'url' and 'context' where context is the line in which the 'url' appeared.
When calling it like $mail->extract_urls(unique => 1), duplicate URLs will be filtered out regardless of the 'context'. That's useful
if you just want a list of all URLs that can be found in your mails.
$body->error() will return a string if no URLs could be found within the body.
quotes
Returns a hash-ref of array-refs where the hash-keys are the several levels of quotation. Each array-element contains the paragraphs of
this quotation-level as one string. Example:
my $quotes = $msg->body($msg->find_body)->quotes;
print $quotes->{1}->[0], "
";
print $quotes->{0}->[0], "
";
This should print the first paragraph of the mail-body that has been quoted once and below that the paragraph that supposedly is the
reply to this paragraph. Perhaps thus:
> I had been trying to work with the CGI module
> but I didn't yet fully understand it.
Ah, it is tricky. Have you read the CGI-FAQ that
comes with the module?
Mark that empty lines will not be ignored and are part of the lines contained in the array of $quotes->{0}.
So below is a little code-snippet that should, in most cases, restore the first 5 paragraphs (containing quote-level 0 and 1) of an
email:
for (0 .. 4) {
print $quotes->{0}->[$_];
print $quotes->{1}->[$_];
}
Since quotes() considers an empty line between two quotes paragraphs as a paragraph in $quotes->{0}, the paragraphs with one quote and
those with zero are balanced. That means:
scalar @{$quotes->{0}} - DIFF == scalar @{$quotes->{1}} where DIFF is element of {-1, 0, 1}.
Unfortunately, quotes() can up to now only deal with '>' as quotation-marks.
VERSION
This is version 0.55.
AUTHOR AND COPYRIGHT
Tassilo von Parseval <tassilo.von.parseval@rwth-aachen.de>
Copyright (c) 2001-2005 Tassilo von Parseval. This program is free software; you can redistribute it and/or modify it under the same
terms as Perl itself.
SEE ALSO perl v5.12.3 2005-12-08 MboxParser::Mail::Body(3pm)