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
Need an AWK script to calculate the percentage bobprabhu Shell Programming and Scripting 8 11-07-2008 05:42 AM
Awk help needed to calculate total senthilkumar_ak Shell Programming and Scripting 7 08-22-2008 01:47 AM
grep running total/ final total across multiple files MrAd UNIX for Dummies Questions & Answers 5 05-08-2007 02:03 PM
Need to total numbers at end of script wereyou Shell Programming and Scripting 9 09-22-2006 08:47 PM
Please Help ( Calculate time taken in a script) sanjay92 UNIX for Dummies Questions & Answers 9 10-02-2001 03:20 PM

 
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 11-24-2008
appsguy616 appsguy616 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 27
awk script to calculate total

Hi
First field is the Record Type. A Record Type 5 can have multiple Record Type 6's before another Record Type 5 appears.

I want to calculate the total of fields at position 8-11 on Record type 6 when Record Type 5 has a field at position 11-14 equals to '2222'. then it should delete the lines of Record Type 6 except the the first Record Type 6 for that Record Type 5 only. Please help

1 101 201 301
5 test 4444 1233
6 1212 1222 3434 33
7 6464 122
8 3664 123
5 test 2222 1233
6 1212 1222 3434 33
7 4464 322
6 1212 4222 3434 33
7 4464 522
6 1212 6222 3434 33
6 1212 7222 3434 33
8 8664 823
5 test 4444 1233
6 1212 1222 3434 33
7 2464 122
8 3664 123
5 test 4444 1233
6 1212 1222 3434 33
7 7464 122
8 5664 123
5 test 2222 1233
6 61212 1222 3434 33
7 6764 122
8 9664 123
9 3332434 334344


so the output should be

1 101 201 301
5 test 4444 1233
6 1212 1222 3434 33
7 6464 122
8 3664 123
5 test 2222 1233
6 1212 18888 3434 33
7 4464 322
7 4464 522
8 8664 823
5 test 4444 1233
6 1212 1222 3434 33
7 2464 122
8 3664 123
5 test 4444 1233
6 1212 1222 3434 33
7 7464 122
8 5664 123
5 test 2222 1233
6 61212 1222 3434 33
7 6764 122
8 9664 123
9 3332434 334344
 

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:19 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