Matches columns from two different files in shell script

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

 
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:
Mod Comment Please use CODE tags as required by forum rules!

Moderator's Comments:
Mod Comment 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
# 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?

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
awk add all columns if column 1 name matches oraclermanpt Shell Programming and Scripting 1 05-09-2018 01:02 PM
Format columns and heads using shell script dellanicholson UNIX for Beginners Questions & Answers 11 11-30-2016 02:43 PM
Help in adding text before columns in shell script Cva2568 Shell Programming and Scripting 5 07-29-2016 06:04 AM
Shell script to convert rows to columns Suneel Mekala Shell Programming and Scripting 1 07-17-2014 10:46 AM
Print Matches to New Columns winkleman UNIX for Dummies Questions & Answers 2 07-03-2014 10:56 AM
Compare 2 files and print matches and non-matches in separate files AshwaniSharma09 Shell Programming and Scripting 7 03-12-2013 10:50 AM
Merge two columns from two files into one if another column matches pbluescript Shell Programming and Scripting 8 10-30-2012 06:58 AM
how to arrange datas in columns in shell script. vashece Shell Programming and Scripting 6 08-22-2012 03:56 PM
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
Comparing the matches in two files using awk when both files have their own field separators asyed Shell Programming and Scripting 2 09-24-2011 06:46 AM
Extract columns where header matches a given string flotsam Shell Programming and Scripting 20 03-19-2011 02:43 AM
Appending columns of two files using shell script siri_886 Shell Programming and Scripting 1 12-22-2010 10:59 AM
edit columns in unix shell script kingpeejay Shell Programming and Scripting 10 06-22-2009 09:01 PM
Joining columns from two files, if the key matches sk_sd Shell Programming and Scripting 1 06-20-2008 08:58 PM
Shell script to separte columns... sam_78_nyc Shell Programming and Scripting 2 07-09-2007 06:21 PM