Sponsored Content
Full Discussion: Merge two files by condition
Top Forums Shell Programming and Scripting Merge two files by condition Post 302715111 by mikezang on Saturday 13th of October 2012 10:17:35 PM
Old 10-13-2012
Quote:
Originally Posted by bartus11
Are you by any chance running this code on Solaris?
Sorry, I only have chance to run it on Mac..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help in merge files

I have created these files in a particular directory a_1.txt a_2.txt ... .. a_n.txt Each file has a single line. I want to write a output file a.txt, which will have concantated value of string from all the files. which utility should i use. copy, cat or paste???? Can anyone help... (5 Replies)
Discussion started by: u263066
5 Replies

2. Shell Programming and Scripting

how to merge these two files?

I have two files, each of them has 12 lines, fileA has 3 columns, fileB has 1 column, like the following FileA a 1 b 2 c 3 ..blabla FileB A B C ..blabla Now I am trying to put the content of fileB as column 3 of fileA, e.g. a 1 A b 2 B c 3 C (3 Replies)
Discussion started by: fedora
3 Replies

3. Shell Programming and Scripting

Merge files of differrent size with one field common in both files using awk

hi, i am facing a problem in merging two files using awk, the problem is as stated below, file1: A|B|C|D|E|F|G|H|I|1 M|N|O|P|Q|R|S|T|U|2 AA|BB|CC|DD|EE|FF|GG|HH|II|1 .... .... .... file2 : 1|Mn|op|qr (2 Replies)
Discussion started by: shashi1982
2 Replies

4. Shell Programming and Scripting

merge files

hi i have two files file1 1234567 1234678 1234679 file2 98765|jjkskk|9393|iyutr 98765|kkooo|9393|hjjjd 98765|abcvfg|9393|sskds output should be 1234567|jjkskk|9393|iyutr 1234678|kkooo|9393|hjjjd 1234679|abcvfg|9393|sskds (5 Replies)
Discussion started by: mad_man12
5 Replies

5. Shell Programming and Scripting

Merge 2 files

Hello, i'd like a bash script to merge 2 files without duplicate lines. Example : file1 : toto titi file2 : toto tata Expected result, file3 : toto (5 Replies)
Discussion started by: Celmar
5 Replies

6. Shell Programming and Scripting

How to compare 2 files & get only few columns based on a condition related to both files?

Hiiiii friends I have 2 files which contains huge data & few lines of it are as shown below File1: b.dat(which has 21 columns) SSR 1976 8 12 13 10 44.00 39.0700 70.7800 7.0 0 0.00 0 2.78 0.00 0.00 0 0.00 2.78 0 NULL ISC 1976 8 12 22 32 37.39 36.2942 70.7338... (6 Replies)
Discussion started by: reva
6 Replies

7. UNIX for Dummies Questions & Answers

Merge files

Hi, I would like to know how can I merge files based on their coordinates, but mantaining the score of each file in the output file like: Note: 1st column is for chromosome, 2nd for start, 3rd for end of segment, 4th for score file1: 1 200 300 20 1 400 500 30 file2: 1 200 350 30 1... (1 Reply)
Discussion started by: fadista
1 Replies

8. Shell Programming and Scripting

Checking in a directory how many files are present and basing on that merge all the files

Hi, My requirement is,there is a directory location like: :camp/current/ In this location there can be different flat files that are generated in a single day with same header and the data will be different, differentiated by timestamp, so i need to verify how many files are generated... (10 Replies)
Discussion started by: srikanth_sagi
10 Replies

9. Shell Programming and Scripting

How to merge two files?

Hi Gurus, I have two files as below file1 abc cde cdd cdf file2 123 234 345 456 I want to get abc 123 cde 234 cdd 345 (3 Replies)
Discussion started by: ken6503
3 Replies

10. Shell Programming and Scripting

Merge files and generate a resume in two files

Dear Gents, Please I need your help... I need small script :) to do the following. I have a thousand of files in a folder produced daily. I need first to merge all files called. txt (0009.txt, 0010.txt, 0011.txt) and and to output a resume of all information on 2 separate files in csv... (14 Replies)
Discussion started by: jiam912
14 Replies
RT::Client::REST(3pm)					User Contributed Perl Documentation				     RT::Client::REST(3pm)

NAME
RT::Client::REST -- talk to RT installation using REST protocol. SYNOPSIS
use Error qw(:try); use RT::Client::REST; my $rt = RT::Client::REST->new( server => 'http://example.com/rt', timeout => 30, ); try { $rt->login(username => $user, password => $pass); } catch Exception::Class::Base with { die "problem logging in: ", shift->message; }; try { # Get ticket #10 $ticket = $rt->show(type => 'ticket', id => 10); } catch RT::Client::REST::UnauthorizedActionException with { print "You are not authorized to view ticket #10 "; } catch RT::Client::REST::Exception with { # something went wrong. }; DESCRIPTION
RT::Client::REST is /usr/bin/rt converted to a Perl module. I needed to implement some RT interactions from my application, but did not feel that invoking a shell command is appropriate. Thus, I took rt tool, written by Abhijit Menon-Sen, and converted it to an object- oriented Perl module. USAGE NOTES
This API mimics that of 'rt'. For a more OO-style APIs, please use RT::Client::REST::Object-derived classes: RT::Client::REST::Ticket and RT::Client::REST::User. not implemented yet). METHODS
new () The constructor can take these options (note that these can also be called as their own methods): server server is a URI pointing to your RT installation. If you have already authenticated against RT in some other part of your program, you can use _cookie parameter to supply an object of type HTTP::Cookies to use for credentials information. timeout timeout is the number of seconds HTTP client will wait for the server to respond. Defaults to LWP::UserAgent's default timeout, which is 300 seconds. basic_auth_cb This callback is to provide the HTTP client (based on LWP::UserAgent) with username and password for basic authentication. It takes the same arguments as "get_basic_credentials()" of LWP::UserAgent and returns username and password: $rt->basic_auth_cb( sub { my ($realm, $uri, $proxy) = @_; # do some evil things return ($username, $password); } login (username => 'root', password => 'password') =item login (my_userfield => 'root', my_passfield => 'password') Log in to RT. Throws an exception on error. Usually, if the other side uses basic HTTP authentication, you do not have to log in, but rather prodive HTTP username and password instead. See basic_auth_cb above. show (type => $type, id => $id) Return a reference to a hash with key-value pair specifying object $id of type $type. edit (type => $type, id => $id, set => { status => 1 }) Set fields specified in parameter set in object $id of type $type. create (type => $type, set => \%params, text => $text) Create a new object of type $type and set initial parameters to %params. For a ticket object, 'text' parameter can be supplied to set the initial text of the ticket. Returns numeric ID of the new object. If numeric ID cannot be parsed from the response, RT::Client::REST::MalformedRTResponseException is thrown. search (type => $type, query => $query, %opts) Search for object of type $type by using query $query. For example: # Find all stalled tickets my @ids = $rt->search( type => 'ticket', query => "Status = 'stalled'", ); %opts is a list of key-value pairs: orderby The value is the name of the field you want to sort by. Plus or minus sign in front of it signifies ascending order (plus) or descending order (minus). For example: # Get all stalled tickets in reverse order: my @ids = $rt->search( type => 'ticket', query => "Status = 'stalled'", orderby => '-id', ); "search" returns the list of numeric IDs of objects that matched your query. You can then use these to retrieve object information using "show()" method: my @ids = $rt->search( type => 'ticket', query => "Status = 'stalled'", ); for my $id (@ids) { my ($ticket) = $rt->show(type => 'ticket', ids => [$id]); print "Subject: ", $t->{Subject}, " "; } comment (ticket_id => $id, message => $message, %opts) Comment on a ticket with ID $id. Optionally takes arguments cc and bcc which are references to lists of e-mail addresses and attachments which is a list of filenames to be attached to the ticket. $rt->comment( ticket_id => 5, message => "Wild thing, you make my heart sing", cc => [qw(dmitri@localhost some@otherdude.com)], ); correspond (ticket_id => $id, message => $message, %opts) Add correspondence to ticket ID $id. Takes optional cc, bcc, and attachments parameters (see "comment" above). get_attachment_ids (id => $id) Get a list of numeric attachment IDs associated with ticket $id. get_attachment (parent_id => $parent_id, id => $id) Returns reference to a hash with key-value pair describing attachment $id of ticket $parent_id. (parent_id because -- who knows? -- maybe attachments won't be just for tickets anymore in the future). get_transaction_ids (parent_id => $id, %opts) Get a list of numeric IDs associated with parent ID $id. %opts have the following options: type Type of the object transactions are associated wtih. Defaults to "ticket" (I do not think server-side supports anything else). This is designed with the eye on the future, as transactions are not just for tickets, but for other objects as well. transaction_type If not specified, IDs of all transactions are returned. If set to a scalar, only transactions of that type are returned. If you want to specify more than one type, pass an array reference. Transactions may be of the following types (case-sensitive): AddLink AddWatcher Comment Correspond Create CustomField DeleteLink DelWatcher EmailRecord Give Set Status Steal Take Told get_transaction (parent_id => $id, id => $id, %opts) Get a hashref representation of transaction $id associated with parent object $id. You can optionally specify parent object type in %opts (defaults to 'ticket'). merge_tickets (src => $id1, dst => $id2) Merge ticket $id1 into ticket $id2. link_tickets (src => $id1, dst => $id2, link_type => $type) Create a link between two tickets. A link type can be one of the following: o DependsOn o DependedOnBy o RefersTo o ReferredToBy o HasMember o MemberOf unlink_tickets (src => $id1, dst => $id2, link_type => $type) Remove a link between two tickets (see link_tickets()) take (id => $id) Take ticket $id. This will throw "RT::Client::REST::AlreadyTicketOwnerException" if you are already the ticket owner. untake (id => $id) Untake ticket $id. This will throw "RT::Client::REST::AlreadyTicketOwnerException" if Nobody is already the ticket owner. steal (id => $id) Steal ticket $id. This will throw "RT::Client::REST::AlreadyTicketOwnerException" if you are already the ticket owner. EXCEPTIONS
When an error occurs, this module will throw exceptions. I recommend using Error.pm's try{} mechanism to catch them, but you may also use simple eval{}. The former will give you flexibility to catch just the exceptions you want. Please see RT::Client::REST::Exception for the full listing and description of all the exceptions. LIMITATIONS
Beginning with version 0.14, methods "edit()" and "show()" only support operating on a single object. This is a conscious departure from semantics offered by the original tool, as I would like to have a precise behavior for exceptions. If you want to operate on a whole bunch of objects, please use a loop. DEPENDENCIES
The following modules are required: o Error o Exception::Class o LWP o HTTP::Cookies o HTTP::Request::Common SEE ALSO
LWP::UserAgent, RT::Client::REST::Exception BUGS
Most likely. Please report. VARIOUS NOTES
RT::Client::REST does not (at the moment, see TODO file) retrieve forms from RT server, which is either good or bad, depending how you look at it. VERSION
This is version 0.40 of RT::Client::REST. AUTHORS
Original /usr/bin/rt was written by Abhijit Menon-Sen <ams@wiw.org>. rt was later converted to this module by Dmitri Tikhonov <dtikhonov@yahoo.com>. In January of 2008, Damien "dams" Krotkine <dams@cpan.org> joined as the project's co-maintainer. JLMARTIN has become co-maintainer as of March 2010. LICENSE
Since original rt is licensed under GPL, so is this module. perl v5.14.2 2012-01-09 RT::Client::REST(3pm)
All times are GMT -4. The time now is 08:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy