(hard one) awk, copy matching 2 col & 10-12 rows, is it possible?
Hey guys, my first post here.
I'm trying to use awk to copy all matching paragraphs from one file
The file looks like this :
Code:
Test Case Number 990990003099
Card Type CCCC
Transaction Type Sale
Entry Mode Keyed
Account Number 4099562299219923
Transaction Amount 78.88
Description lorem ipsum lorem ipsum
AVS Billing Postal Code 99999
Response Code 999
AVS Result Code A
Test Case Number 000990003099
Card Type CCCC
Transaction Type Sale
Entry Mode Keyed
Account Number 4909969931992993
Transaction Amount 78.90
Description lorem ipsum lorem ipsum
AVS Billing Postal Code 99999
Response Code 999
AVS Result Code Z
I need to copy from the line that says "Test Case" to another "Test case" if the "Transaction Type" equals a certain word, ether, "Sale", "Refund" or other type that I set.
The data set is spread across 2 columns and 10-12 rows.
Is it possible to copy with awk? If yes, then ... how?
Thank you, your help is greatly appreciated.
Last edited by Don Cragun; 06-01-2015 at 07:06 PM..
Reason: Add CODE tags.
Hi
I have 2 75GB SCSI hard drives and 2 250GB SATA hard drives which are using RAID Level 1 respectively. I wana have both FTP and Apache installed on them as services. I'm wondering what's the best partitioning schem? I wana use FC3 as my OS, so, I thought I can use the 75GB hard drive as the /... (0 Replies)
I have file
"1","x1897"," 89.10"
"1","x2232"," -12.12"
"1","x1897"," 389.10"
"1","x2232"," 212.12"
"1","x1897"," 19.10"
"1","x2232"," 2.12"
i want to add all 3 rd column rows (they have spaces also)for x1
and sum of 3rd column rows for x2 separately.
I am very... (8 Replies)
Hello,
Despite reading the Pattern Matching chapter in the O'Reilly Sed & Awk book several times and
looking at numerous examples, I cannot seem to get any kind of conditional script to work in my awk scripts!
I am able to do the basic awk and grep script to capture the data but when I do with... (0 Replies)
Experts,
I am a beginner to Unix Shell Scripting
We have source as a flat file which contains CTRL+F character as the delimiter. We need to count the number of records in the file (CTRL+F) to perform file validation
Following command being used:
awk '{cnt+=gsub(//,"&")}END {print cnt}'... (4 Replies)
Hello everyone,
I am writing a script to process data from the ATP world tour.
I have a file which contains:
t=540 y=2011 r=1 p=N409
t=540 y=2011 r=2 p=N409
t=540 y=2011 r=3 p=N409
t=540 y=2011 r=4 p=N409
t=520 y=2011 r=1 p=N409
t=520 y=2011 r=2 p=N409
t=520 y=2011 r=3 p=N409
The... (4 Replies)
Hello,
I have some tab delimited data and I need to move the last col. I could hard code it,
awk '{ print $1,$NF,$2,$3,$4,etc }' infile > outfile
but it would be nice to know the syntax to print a range cols.
I know in cut you can do,
cut -f 1,4-8,11-
to print fields 1,... (8 Replies)
Hi,
Please help with this.
I have several excel files (with and .xlsx format) with 10-15 columns each.
They all have the same type of data but the columns are not ordered in the same way.
Here is a 3 column example. What I want to do add the alphabet
from column 2 to column 3, provided... (9 Replies)
Hi
I have a problem in using awk in GAMS. I have to copy a part of a .txt file selecting the rows between these two lines
"0 / END OF TRANSFORMER DATA, BEGIN AREA DATA"
"0 / END OF AREA DATA, BEGIN TWO-TERMINAL DC DATA"
I thought of using a command like this:
$onecho > area.awk... (4 Replies)
Hello Help,
2356798 7689867 999 000
123678 20385907 9797 666
17978975 87468976 968978 98798
I am trying to have out put which actually look for the third column value of 9797 and then it insert line there after with first, second column value exactly as the previous line and replace the third... (3 Replies)
Mojo::Transaction(3pm) User Contributed Perl Documentation Mojo::Transaction(3pm)NAME
Mojo::Transaction - Transaction base class
SYNOPSIS
use Mojo::Base 'Mojo::Transaction';
DESCRIPTION
Mojo::Transaction is an abstract base class for transactions.
EVENTS
Mojo::Transaction can emit the following events.
"connection"
$tx->on(connection => sub {
my ($tx, $connection) = @_;
...
});
Emitted when a connection has been assigned to transaction.
"finish"
$tx->on(finish => sub {
my $tx = shift;
...
});
Emitted when transaction is finished.
"resume"
$tx->on(resume => sub {
my $tx = shift;
...
});
Emitted when transaction is resumed.
ATTRIBUTES
Mojo::Transaction implements the following attributes.
"kept_alive"
my $kept_alive = $tx->kept_alive;
$tx = $tx->kept_alive(1);
Connection has been kept alive.
"local_address"
my $local_address = $tx->local_address;
$tx = $tx->local_address($address);
Local interface address.
"local_port"
my $local_port = $tx->local_port;
$tx = $tx->local_port($port);
Local interface port.
"previous"
my $previous = $tx->previous;
$tx = $tx->previous(Mojo::Transaction->new);
Previous transaction that triggered this followup transaction.
# Path of previous request
say $tx->previous->req->url->path;
"remote_address"
my $remote_address = $tx->remote_address;
$tx = $tx->remote_address($address);
Remote interface address.
"remote_port"
my $remote_port = $tx->remote_port;
$tx = $tx->remote_port($port);
Remote interface port.
"req"
my $req = $tx->req;
$tx = $tx->req(Mojo::Message::Request->new);
HTTP 1.1 request, defaults to a Mojo::Message::Request object.
"res"
my $res = $tx->res;
$tx = $tx->res(Mojo::Message::Response->new);
HTTP 1.1 response, defaults to a Mojo::Message::Response object.
METHODS
Mojo::Transaction inherits all methods from Mojo::EventEmitter and implements the following new ones.
"client_close"
$tx->client_close;
Transaction closed.
"client_read"
$tx->client_read($chunk);
Read and process client data. Meant to be overloaded in a subclass.
"client_write"
my $chunk = $tx->client_write;
Write client data. Meant to be overloaded in a subclass.
"connection"
my $connection = $tx->connection;
$tx = $tx->connection($connection);
Connection identifier or socket.
"error"
my $message = $tx->error;
my ($message, $code) = $tx->error;
Parser errors and codes.
"is_finished"
my $success = $tx->is_finished;
Check if transaction is finished.
"is_websocket"
my $false = $tx->is_websocket;
False.
"is_writing"
my $success = $tx->is_writing;
Check if transaction is writing.
"resume"
$tx = $tx->resume;
Resume transaction.
"server_close"
$tx->server_close;
Transaction closed.
"server_read"
$tx->server_read($chunk);
Read and process server data. Meant to be overloaded in a subclass.
"server_write"
my $chunk = $tx->server_write;
Write server data. Meant to be overloaded in a subclass.
"success"
my $res = $tx->success;
Returns the Mojo::Message::Response object ("res") if transaction was successful or "undef" otherwise. Connection and parser errors have
only a message in "error", 400 and 500 responses also a code.
# Sensible exception handling
if (my $res = $tx->success) {
say $res->body;
}
else {
my ($message, $code) = $tx->error;
if ($code) {
say "$code $message response.";
}
else {
say "Connection error: $message";
}
}
Error messages can be accessed with the "error" method of the transaction object.
SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>.
perl v5.14.2 2012-09-05 Mojo::Transaction(3pm)