The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
multiplication shows syntax error sonicstage UNIX for Dummies Questions & Answers 4 08-07-2008 12:21 PM
Multiplication with Fractions alby Linux 1 07-07-2008 12:25 PM
Multiplication Station 0.5.2 (Default branch) iBot Software Releases - RSS News 0 05-17-2008 08:40 AM
Multiplication Station 0.5.0 (Default branch) iBot Software Releases - RSS News 0 02-11-2008 01:20 PM
Simple multiplication problem greekozz UNIX for Dummies Questions & Answers 8 07-06-2007 10:32 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 12-04-2008
cdfd123 cdfd123 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 112
using awk multiplication

Suppose i have a file A
1*2*3*4
2*4*4*22

and second file B
2*3*4*5
4*4*6*7


By multiplying file A by file B that is file A by first column in file B respectively
output shud be

2*6*12*20
8*16*24*154



my code is
[CODE][/
for a in A
do
for FILE in B
do
awk 'NR==FNR {
x[FNR] =$1
next
}
{for (f=1;f<=NF;f++)
$f*= x[FNR]
} 1' OFS='*' FS='*' $a $FILE >file_output
done
done
CODE]

then output was
2*3*4*5
8*8*12*14
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




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


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0