×
UNIX.COM Login
Username:
Password:  
Show Password






👤


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

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

👤 Login to reply

 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-14-2017
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 06:22 AM.. Reason: Added CODE tags, moved to "Beginners" forum
Sponsored Links
    #2  
Old 12-14-2017
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 16 July 2018, 7:55 AM EDT
Location: Aachen, Germany
Posts: 13,059
Thanks: 447
Thanked 4,008 Times in 3,685 Posts
Welcome to the forum.

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 05:58 AM
Sum up values of columns in 4 files using shell script reach.sree@gmai Shell Programming and Scripting 2 06-06-2012 10:20 PM
Appending columns of two files using shell script siri_886 Shell Programming and Scripting 1 12-22-2010 09:59 AM
Joining columns from two files, if the key matches sk_sd Shell Programming and Scripting 1 06-20-2008 07:58 PM



All times are GMT -4. The time now is 08:41 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.