Unix/Linux Go Back    


UNIX for Beginners Questions & Answers If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

Matches columns from two different files in shell script

UNIX for Beginners Questions & Answers


Tags
awk-if, nr==fnr, shell command line arguments, shell script awk, shell script commands

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 12-14-2017   -   Original Discussion by bhaskar illa
bhaskar illa's Unix or Linux Image
bhaskar illa bhaskar illa is offline
Registered User
 
Join Date: Dec 2017
Last Activity: 14 December 2017, 4:38 AM EST
Location: hyderabad
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Linux Matches columns from two different files in shell script

Hi friends,
i want to compare first columns from two different files ,if equal print the file2's second column else print the zero.Please help me...
file1:


Code:
a
b
c
d
e

file2:


Code:
a 1
c 20
e 30
desired output:
1
0
20
0
30

Moderator's Comments:
Matches columns from two different files in shell script Please use CODE tags as required by forum rules!

Moderator's Comments:
Matches columns from two different files in shell script Please post in an adequate forum!

Last edited by RudiC; 12-14-2017 at 07:22 AM.. Reason: Added CODE tags, moved to "Beginners" forum
Sponsored Links
    #2  
Old Unix and Linux 12-14-2017   -   Original Discussion by bhaskar illa
RudiC's Unix or Linux Image
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 19 January 2018, 11:36 AM EST
Location: Aachen, Germany
Posts: 11,958
Thanks: 353
Thanked 3,687 Times in 3,385 Posts
Welcome to the forum.

This is a problem dealt with umpteen times in here. Any attempts / ideas / thoughts from your side?
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Merge two columns from two files into one if another column matches pbluescript Shell Programming and Scripting 8 10-30-2012 06:58 AM
Sum up values of columns in 4 files using shell script reach.sree@gmai Shell Programming and Scripting 2 06-06-2012 11:20 PM
Appending columns of two files using shell script siri_886 Shell Programming and Scripting 1 12-22-2010 10:59 AM
Joining columns from two files, if the key matches sk_sd Shell Programming and Scripting 1 06-20-2008 08:58 PM



All times are GMT -4. The time now is 04:48 PM.