Home Man
Search
Today's Posts
Register

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
# 1  
Old 12-14-2017
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
# 2  
Old 12-14-2017
Welcome to the forum.

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

« Previous Thread | Next Thread »
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
awk add all columns if column 1 name matches oraclermanpt Shell Programming and Scripting 1 05-09-2018 12:02 PM
Print Matches to New Columns winkleman UNIX for Dummies Questions & Answers 2 07-03-2014 09:56 AM
Shell Script @ Find a key word and If the key word matches then replace next 7 lines only Rajeev_hbk Shell Programming and Scripting 4 05-06-2014 12:25 PM
Compare 2 files and print matches and non-matches in separate files AshwaniSharma09 Shell Programming and Scripting 7 03-12-2013 09:50 AM
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
Extract columns where header matches a given string flotsam Shell Programming and Scripting 20 03-19-2011 01:43 AM
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
Shell script to separte columns... sam_78_nyc Shell Programming and Scripting 2 07-09-2007 05:21 PM


All times are GMT -4. The time now is 03:47 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password