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
AWK subtraction in multiple columns awkward Shell Programming and Scripting 2 01-16-2009 09:11 AM
Combine multiple columns from multiple files martva Shell Programming and Scripting 5 12-02-2008 09:23 AM
sum numbers in multiple files pattywac Shell Programming and Scripting 5 07-21-2008 06:21 PM
how to find a sum of multiple numbers aoussenko Shell Programming and Scripting 3 06-16-2008 03:01 PM
sorting a file with multiple columns outtacontrol UNIX for Dummies Questions & Answers 3 07-26-2006 02:51 PM

Closed Thread
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
  #1 (permalink)  
Old 01-18-2009
awkward awkward is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 5
AWK solution to subtract multiple columns of numbers

Hope somebody is happy.

NR==1 {
num_columns=split( $0, menuend );
next;
}

{
split( $0, substrend );
for ( i=1; i<=NF; i++ ) {
minuend[i] -= substrend[i];
}
}

END {
print "Result:";
for ( i=1; i<=num_columns; i++ ) {
printf( "%8d", menuend[i] );
}
printf "\n";
}
  #2 (permalink)  
Old 01-18-2009
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,945
And your question is?
  #3 (permalink)  
Old 01-18-2009
Rhije Rhije is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 103
haha, this wasn't a question, it was a solution to a question in another thread, I am guess they couldn't find it.

AWK subtraction in multiple columns
  #4 (permalink)  
Old 01-18-2009
awkward awkward is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 5
You are right it is a solution to my previous threads, I solved it and posted for someone who has same problem.

Regards,
awkward
Closed Thread

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 07:22 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