If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > AWK Scripting

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-19-03, 22:52
rrohde rrohde is offline
Registered User
 
Join Date: Nov 2003
Location: Australia
Posts: 2
AWK Scripting

Hi all,

Im reallativly new to unix so please forgive any technical mistypes.

Im currently trying to setup a AWK script that converts my comma delimited text file to User specific files with all times and downloads calculated.

my file has 13 fields
server name-$1 , name-$2 , port no-$3 , in date-$4 , in time-$5 , out date-$6 , out time-$7 , min-$8 , bytes sent-$9 , bytes received-$10 , port speed-$11 , how off-$12 , unique id-$13

How do I output this file to individual files named $2.txt and then total all the times ($8) and bytes downloaded ($9) and bytes uploaded ($10) in those new pages.

Thank you for your time.

Regards
Richard Rohde
Reply With Quote
  #2 (permalink)  
Old 11-20-03, 07:40
gurey gurey is offline
Registered User
 
Join Date: Aug 2003
Location: Argentina
Posts: 780
Re: AWK Scripting

Quote:
Originally posted by rrohde
Hi all,

Im reallativly new to unix so please forgive any technical mistypes.

Im currently trying to setup a AWK script that converts my comma delimited text file to User specific files with all times and downloads calculated.

my file has 13 fields
server name-$1 , name-$2 , port no-$3 , in date-$4 , in time-$5 , out date-$6 , out time-$7 , min-$8 , bytes sent-$9 , bytes received-$10 , port speed-$11 , how off-$12 , unique id-$13

How do I output this file to individual files named $2.txt and then total all the times ($8) and bytes downloaded ($9) and bytes uploaded ($10) in those new pages.

Thank you for your time.

Regards
Richard Rohde
Hi Richard,

Check this:

#!/bin/ksh
cat filename|awk -F',' 'BEGIN {t1=0} {t2=0} {t3=0} {t1+=$8} {t2+=$9} {t3+=$10} END {printf "%d\t%d\t%d\n",t1,t2,t3}'

Gustavo.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On