Sponsored Content
Top Forums Shell Programming and Scripting How to merge two files with unique values matching.? Post 302924056 by RavinderSingh13 on Thursday 6th of November 2014 04:08:07 AM
Old 11-06-2014
Hello Sharma331,

Following may help you in same.

Code:
awk 'FNR==NR{A[$1]=$2 OFS $3;next} ($5 in A){print $0 OFS A[$5]}' outputfile2.xls OFS="\t" outputfile1.xls

Output will be as follows.
Code:
hobby  class  subject  sports  rollNumber       First_name last_name
dance  11     science  cricket   1      sonali kumari
dance  12     science  cricket   3      Rini kumari
dance  10     science  cricket   1      sonali kumari
dance  11     science  cricket   2      anni Das
dance  11     science  cricket   1      sonali kumari
dance  11     science  cricket   2      anni Das


Thanks,
R. Singh
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need to find only unique values for a given tag across the files

Need to find only unique values for a given tag across the files: For eg: Test1: <Tag1>aaa</Tag1> <Tag2>bbb</Tag2> <Tag3>ccc</Tag3> Test2: <Tag1>aaa</Tag1> <Tag2>ddd</Tag2> <Tag3>eee</Tag3> Test3: <Tag1>aaa</Tag1> <Tag2>ddd</Tag2> <Tag3>eee</Tag3> Test4: (8 Replies)
Discussion started by: sudheshnaiyer
8 Replies

2. Shell Programming and Scripting

comparing 2 text files to get unique values??

Hi all, I have got a problem while comparing 2 text files and the result should contains the unique values(Non repeatable). For eg: file1.txt 1 2 3 4 file2.txt 2 3 So after comaping the above 2 files I should get only 1 and 4 as the output. Pls help me out. (7 Replies)
Discussion started by: smarty86
7 Replies

3. Shell Programming and Scripting

merge files with same row values

Hi everyone, I'm just wondering how could I using awk language merge two files by comparison of one their row. I mean, I have one file like this: file#1: 21/07/2009 11:45:00 100.0000000 27.2727280 21/07/2009 11:50:00 75.9856644 25.2492676 21/07/2009 11:55:00 51.9713287 23.2258072... (4 Replies)
Discussion started by: tonet
4 Replies

4. Shell Programming and Scripting

Compare values in two files. For matching rows print corresponding values from File 1 in File2.

- I have two files (File 1 and File 2) and the contents of the files are mentioned below. - I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2. - I tried to modify and use... (10 Replies)
Discussion started by: Santoshbn
10 Replies

5. Shell Programming and Scripting

Merge two files matching columns

Hi! I need to merge two files when col1 (x:x:x) matching and adds second column from file1.txt. # cat 1.txt aaa;a12 bbb;b13 ccc;c33 ddd;d55 eee;e11 # cat 2.txt bbb;b55;34444;d55 aaa;a15;35666;a44 I try with this awk and I get succesfully first column from 1.txt: # awk -F";"... (2 Replies)
Discussion started by: fhluque
2 Replies

6. UNIX for Dummies Questions & Answers

Grep to find matching patern and return unique values

Request: grep to find given matching patern and return unique values, eliminate the duplicate values I have to retrieve the unique folder on the below file contents like; /app/oracle/build_lib/pkg320.0_20120927 /app/oracle/build_lib/pkg320.0_20121004_prof... (5 Replies)
Discussion started by: Siva SQL
5 Replies

7. Shell Programming and Scripting

How to merge two or more fields from two different files where there is non matching column?

Hi, Please excuse for often requesting queries and making R&D, I am trying to work out a possibility where i have two files field separated by pipe and another file containing only one field where there is no matching columns, Could you please advise how to merge two files. $more... (3 Replies)
Discussion started by: karthikram
3 Replies

8. Shell Programming and Scripting

Count Unique values from multiple lists of files

Looking for a little help here. I have 1000's of text files within a multiple folders. YYYY/ /MM /1000's Files Eg. 2014/01/1000 files 2014/02/1237 files 2014/03/1400 files There are folders for each year and each month, and within each monthly folder there are... (4 Replies)
Discussion started by: whegra
4 Replies

9. Linux

Merge two files based on matching criteria

Hi, I am trying to merge two csv files based on matching criteria: File description is as below : Key_File : 000|ÇÞ|Key_HF|ÇÞ|Key_FName 001|ÇÞ|Key_11|ÇÞ|Sort_Key22|ÇÞ|Key_31 002|ÇÞ|Key_12|ÇÞ|Sort_Key23|ÇÞ|Key_32 003|ÇÞ|Key_13|ÇÞ|Sort_Key24|ÇÞ|Key_33 050|ÇÞ|Key_15|ÇÞ|Sort_Key25|ÇÞ|Key_34... (3 Replies)
Discussion started by: PK29
3 Replies

10. UNIX for Beginners Questions & Answers

Merge 4 bim files by keeping only the overlapping variants (unique rs values )

Dear community, I am facing a problem and I kindly ask your help: I have 4 different data sets consisted from 3 different types of array. On each file, column 1 is chromosome position, column 2 is SNP id etc... Lets say I have the following (bim) datasets: x2014: 1 rs3094315... (4 Replies)
Discussion started by: fondan
4 Replies
POE::Component::IRC::Plugin::BotAddressed(3pm)		User Contributed Perl Documentation	    POE::Component::IRC::Plugin::BotAddressed(3pm)

NAME
POE::Component::IRC::Plugin::BotAddressed - A PoCo-IRC plugin that generates events when you are addressed SYNOPSIS
use POE::Component::IRC::Plugin::BotAddressed; $irc->plugin_add( 'BotAddressed', POE::Component::IRC::Plugin::BotAddressed->new() ); sub irc_bot_addressed { my ($kernel, $heap) = @_[KERNEL, HEAP]; my $nick = ( split /!/, $_[ARG0] )[0]; my $channel = $_[ARG1]->[0]; my $what = $_[ARG2]; print "$nick addressed me in channel $channel with the message '$what' "; } sub irc_bot_mentioned { my ($nick) = ( split /!/, $_[ARG0] )[0]; my ($channel) = $_[ARG1]->[0]; my ($what) = $_[ARG2]; print "$nick mentioned my name in channel $channel with the message '$what' "; } DESCRIPTION
POE::Component::IRC::Plugin::BotAddressed is a POE::Component::IRC plugin. It watches for public channel traffic (i.e. "irc_public" and "irc_ctcp_action") and will generate an "irc_bot_addressed", "irc_bot_mentioned" or "irc_bot_mentioned_action" event if its name comes up in channel discussion. METHODS
"new" One optional argument: 'eat', set to true to make the plugin eat the "irc_public" / "irc_ctcp_action" event and only generate an appropriate event, default is false. Returns a plugin object suitable for feeding to POE::Component::IRC's "plugin_add" method. OUTPUT EVENTS
"irc_bot_addressed" Has the same parameters passed as "irc_ctcp_public". "ARG2" contains the message with the addressed nickname removed, ie. Assuming that your bot is called LameBOT, and someone says 'LameBOT: dance for me', you will actually get 'dance for me'. "irc_bot_mentioned" Has the same parameters passed as "irc_public". "irc_bot_mentioned_action" Has the same parameters passed as "irc_ctcp_action". AUTHOR
Chris 'BinGOs' Williams <chris@bingosnet.co.uk> perl v5.14.2 2011-12-07 POE::Component::IRC::Plugin::BotAddressed(3pm)
All times are GMT -4. The time now is 06:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy