Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Compare two files, if the columns are same then replace next column with some value Post 303045722 by RudiC on Friday 10th of April 2020 04:12:19 PM
Old 04-10-2020
Try escaping / quoting the pipe character to use it for the field separator; else it will be interpreted by the shell for a command pipeline (and fail).
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

find common lines using just one column to compare and result with all columns

Hi. If we have this file A B C 7 8 9 1 2 10 and this other file A C D F 7 9 2 3 9 2 3 4 The result i´m looking for is intersection with A B C D F so the answer here will be (10 Replies)
Discussion started by: alcalina
10 Replies

2. Ubuntu

How to compare two columns and fetch the common data with additional column

Dear All, I am new to this forum and please ignore my little knowledge :p I have two types of data (a subset is given below) data version 1: 439798 2 1 451209 1 2 508696 2 1 555760 2 1 582757 1 2 582889 1 2 691827... (2 Replies)
Discussion started by: evoll
2 Replies

3. Shell Programming and Scripting

Compare Two Files(Column By Column) In Perl or shell

Hi, I am writing a comparator script, which comapre two txt files(column by column) below are the precondition of this comparator 1)columns of file are not seperated Ex. file1.txt 8888812341181892 1243548895685687 8945896789897789 1111111111111111 file2.txt 9578956789567897... (2 Replies)
Discussion started by: kumar96877
2 Replies

4. Shell Programming and Scripting

awk compare column n replace with in one file

hi Friends need to compare columns in one file where the data looks like below laptop,IBM phone,samsung car,rental user1,laptop user2,laptop user3,phone want to get output as laptop,IBM phone,samsung car,rental user1,IBM user2,IBM user3,samsung need to seach $2 in array of $1 and... (4 Replies)
Discussion started by: arun1401
4 Replies

5. Shell Programming and Scripting

Combine columns from many files but keep them aligned in columns-shorter left column issue

Hello everyone, I searched the forum looking for answers to this but I could not pinpoint exactly what I need as I keep having trouble. I have many files each having two columns and hundreds of rows. first column is a string (can have many words) and the second column is a number.The files are... (5 Replies)
Discussion started by: isildur1234
5 Replies

6. Shell Programming and Scripting

Compare first column of 2 files and replace

Hi All, I have 2 files in the following format : File 1 S00999999|BHANU|TEST|007 JOHN DOE APT 999||VENGA HIGHWAY|MA|09566|SCO DUAL|20140201|20140331|20140401|20140630|20140327| S00888888|BU|TES|009 JOHN DOE APT 909||SENGA HIGHWAY|MA|08566|SCO... (1 Reply)
Discussion started by: nua7
1 Replies

7. Shell Programming and Scripting

Compare 2 csv files by columns, then extract certain columns of matcing rows

Hi all, I'm pretty much a newbie to UNIX. I would appreciate any help with UNIX coding on comparing two large csv files (greater than 10 GB in size), and output a file with matching columns. I want to compare file1 and file2 by 'id' and 'chain' columns, then extract exact matching rows'... (5 Replies)
Discussion started by: bkane3
5 Replies

8. Shell Programming and Scripting

Compare two columns and replacing it with value from third column!!

Hi, I am new to Unix and I am finding it hard to fix a particular logic. The context is as below. File 1 : This contains of 5 fields : Type | Bank Code | Account | Name | Date/Time 60|ABC123|TX123456|XXXX|YYYYMMDDHH:MM:SS 72|ABC123|MYD34561|XXXX|YYYYMMDDHH:MM:SS... (4 Replies)
Discussion started by: DJose
4 Replies

9. Shell Programming and Scripting

Compare and replace two columns from two files

Hello, I have two text tab delimited files File 1 has 30 columns. I am pasting only first 9 Chr Position Ref Alt Score Gene HGVS_C HGVS_P Coding_Consequence dbSNP 1 17312743 C T 1 Gene1 - ... (2 Replies)
Discussion started by: nans
2 Replies

10. Shell Programming and Scripting

Need awk or Shell script to compare Column-1 of two different CSV files and print if column-1 matche

Example: I have files in below format file 1: zxc,133,joe@example.com cst,222,xyz@example1.com File 2 Contains: hxd hcd jws zxc cst File 1 has 50000 lines and file 2 has around 30000 lines : Expected Output has to be : hxd hcd jws (5 Replies)
Discussion started by: TestPractice
5 Replies
Object::Pluggable::Pipeline(3pm)			User Contributed Perl Documentation			  Object::Pluggable::Pipeline(3pm)

NAME
Object::Pluggable::Pipeline - The plugin pipeline for Object::Pluggable. SYNOPSIS
use Object::Pluggable; use Object::Pluggable::Pipeline; use My::Plugin; my $self = Object::Pluggable->new(); # the following operations are presented in pairs # the first is the general procedure, the second is # the specific way using the pipeline directly # to install a plugin $self->plugin_add(mine => My::Plugin->new); $self->pipeline->push(mine => My::Plugin->new); # to remove a plugin $self->plugin_del('mine'); # or the object $self->pipeline->remove('mine'); # or the object # to get a plugin my $plug = $self->plugin_get('mine'); my $plug = $self->pipeline->get('mine'); # there are other very specific operations that # the pipeline offers, demonstrated here: # to get the pipeline object itself my $pipe = $self->pipeline; # to install a plugin at the front of the pipeline $pipe->unshift(mine => My::Plugin->new); # to remove the plugin at the end of the pipeline my $plug = $pipe->pop; # to remove the plugin at the front of the pipeline my $plug = $pipe->shift; # to replace a plugin with another $pipe->replace(mine => newmine => My::Plugin->new); # to insert a plugin before another $pipe->insert_before(mine => newmine => My::Plugin->new); # to insert a plugin after another $pipe->insert_after(mine => newmine => My::Plugin->new); # to get the location in the pipeline of a plugin my $index = $pipe->get_index('mine'); # to move a plugin closer to the front of the pipeline $pipe->bump_up('mine'); # to move a plugin closer to the end of the pipeline $pipe->bump_down('mine'); DESCRIPTION
Object::Pluggable::Pipeline defines the Plugin pipeline system for Object::Pluggable instances. METHODS
"new" Takes one argument, the Object::Pluggable object to attach to. "push" Takes at least two arguments, an alias for a plugin and the plugin object itself. Any extra arguments will be passed to the register method of the plugin object. If a plugin with that alias already exists, $@ will be set and "undef" will be returned. Otherwise, it adds the plugin to the end of the pipeline and registers it. This will yield a "plugin_add" event. If successful, it returns the size of the pipeline. my $new_size = $pipe->push($name, $plug, @register_args); "unshift" Takes at least two arguments, an alias for a plugin and the plugin object itself. Any extra arguments will be passed to the register method of the plugin object. If a plugin with that alias already exists, $@ will be set and "undef" will be returned. Otherwise, it adds the plugin to the beginning of the pipeline and registers it. This will yield a "plugin_add" event. If successful, it returns the size of the pipeline. my $new_size = $pipe->push($name, $plug, @register_args); "shift" Takes any number of arguments. The first plugin in the pipeline is removed. Any arguments will be passed to the unregister method of the plugin object. This will yield a "plugin_del" event. In list context, it returns the plugin and its alias; in scalar context, it returns only the plugin. If there were no elements, an empty list or "undef" will be returned. my ($plug, $name) = $pipe->shift(@unregister_args); my $plug = $pipe->shift(@unregister_args); "pop" Takes any number of arguments. The last plugin in the pipeline is removed. Any arguments will be passed to the unregister method of the plugin object. This will yield an "plugin_del" event. In list context, it returns the plugin and its alias; in scalar context, it returns only the plugin. If there were no elements, an empty list or "undef" will be returned. my ($plug, $name) = $pipe->pop(@unregister_args); my $plug = $pipe->pop(@unregister_args); "replace" Takes at least three arguments, the old plugin or its alias, an alias for the new plugin and the new plugin object itself. You can optionally pass two array references of arguments which will be delivered to the unregister method of the old plugin and the register method of the new plugin, respectively. If you only want to pass the latter, you can put "undef" in place of the former. If the old plugin doesn't exist, or if there is already a plugin with the new alias (besides the old plugin), $@ will be set and "undef" will be returned. Otherwise, it removes the old plugin (yielding an "plugin_del" event) and replaces it with the new plugin. This will yield an "plugin_add" event. If successful, it returns 1. my $success = $pipe->replace($name, $new_name, $new_plug, @unregister_args, @register_args); my $success = $pipe->replace($plug, $new_name, $new_plug, @unregister_args, @register_args); "insert_before" Takes at least three arguments, the plugin that is relative to the operation, an alias for the new plugin and the new plugin object itself. Any extra arguments will be passed to the register method of the new plugin object. If the first plugin doesn't exist, or if there is already a plugin with the new alias, $@ will be set and "undef" will be returned. Otherwise, the new plugin is placed just prior to the other plugin in the pipeline. If successful, it returns 1. my $success = $pipe->insert_before($name, $new_name, $new_plug, @register_args); my $success = $pipe->insert_before($plug, $new_name, $new_plug, @register_args); "insert_after" Takes at least three arguments, the plugin that is relative to the operation, an alias for the new plugin and the new plugin object itself. any extra arguments will be passed to the register method of the new plugin object. If the first plugin doesn't exist, or if there is already a plugin with the new alias, $@ will be set and "undef" will be returned. Otherwise, the new plugin is placed just after to the other plugin in the pipeline. If successful, it returns 1. my $success = $pipe->insert_after($name, $new_name, $new_plug, @register_args); my $success = $pipe->insert_after($plug, $new_name, $new_plug, @register_args); "bump_up" Takes one or two arguments, the plugin or its alias, and the distance to bump the plugin. The distance defaults to 1. If the plugin doesn't exist, $@ will be set and -1 will be returned, not undef. Otherwise, the plugin will be moved the given distance closer to the front of the pipeline. A warning is issued alerting you if it would have been moved past the beginning of the pipeline, and the plugin is placed at the beginning. If successful, the new index of the plugin in the pipeline is returned. my $pos = $pipe->bump_up($name); my $pos = $pipe->bump_up($plug); my $pos = $pipe->bump_up($name, $delta); my $pos = $pipe->bump_up($plug, $delta); "bump_down" Takes one or two arguments, the plugin or its alias, and the distance to bump the plugin. The distance defaults to 1. If the plugin doesn't exist, $@ will be set and -1 will be returned, not "undef". Otherwise, the plugin will be moved the given distance closer to the end of the pipeline. A warning is issued alerting you if it would have been moved past the end of the pipeline, and the plugin is placed at the end. If successful, the new index of the plugin in the pipeline is returned. my $pos = $pipe->bump_down($name); my $pos = $pipe->bump_down($plug); my $pos = $pipe->bump_down($name, $delta); my $pos = $pipe->bump_down($plug, $delta); "remove" Takes at least one argument, a plugin or its alias. Any arguments will be passed to the unregister method of the plugin object. If the plugin doesn't exist, $@ will be set and "undef" will be returned. Otherwise, the plugin is removed from the pipeline. This will yield an "plugin_del" event. In list context, it returns the plugin and its alias; in scalar context, it returns only the plugin. my ($plug, $name) = $pipe->remove($the_name, @unregister_args); my ($plug, $name) = $pipe->remove($the_plug, @unregister_args); my $plug = $pipe->remove($the_name, @unregister_args); my $plug = $pipe->remove($the_plug, @unregister_args); "get" Takes one argument, a plugin or its alias. If no such plugin exists, $@ will be set and "undef" will be returned. In list context, it returns the plugin and its alias; in scalar context, it returns only the plugin. my ($plug, $name) = $pipe->get($the_name); my ($plug, $name) = $pipe->get($the_plug); my $plug = $pipe->get($the_name); my $plug = $pipe->get($the_plug); "get_index" Takes one argument, a plugin or its alias. If no such plugin exists, $@ will be set and -1 will be returned, not "undef". Otherwise, the index in the pipeline is returned. my $pos = $pipe->get_index($name); my $pos = $pipe->get_index($plug); BUGS
None known so far. AUTHOR
Jeff "japhy" Pinyan, japhy@perlmonk.org. MAINTAINER
Chris "BinGOs" Williams, chris@bingosnet.co.uk. SEE ALSO
Object::Pluggable. POE::Component::IRC, perl v5.10.1 2010-10-09 Object::Pluggable::Pipeline(3pm)
All times are GMT -4. The time now is 10:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy