Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003
    Location
    Australia
    Posts
    2

    Unanswered: Pls Help with Awk Script

    Hi all, wondering if anyone can help.

    Im currently trying to write a script that takes my users connection stats
    and rewrites it to individual user files.

    the data is in the form of a comma delimited text file

    Fields
    server name$1 ,name,port no,in date,in time,out date,out time,min,bytes sent,bytes received,port speed,how off,unique id

    I know how to format
    How do I set the script to write a file for each new name in $2 and then add up all the times and downloads ($8, $9, $10) in those user specific files .

    Thank you for your assistance

  2. #2
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525

    Re: Pls Help with Awk Script

    Originally posted by rrohde
    Hi all, wondering if anyone can help.

    Im currently trying to write a script that takes my users connection stats
    and rewrites it to individual user files.

    the data is in the form of a comma delimited text file

    Fields
    server name$1 ,name,port no,in date,in time,out date,out time,min,bytes sent,bytes received,port speed,how off,unique id

    I know how to format
    How do I set the script to write a file for each new name in $2 and then add up all the times and downloads ($8, $9, $10) in those user specific files .

    Thank you for your assistance
    I think this should do what you are asking...

    awk -F"," ' {
    time[$2]+=$8
    bytesSent[$2]+=$9
    bytesReceived[$2]+=$10
    }
    END {
    for (fileName in time) {
    print "Time="time[fileName], "Sent="bytesSent[fileName], "Received="bytesReceived[fileName] > fileName
    }
    }' yourFile

    Damian
    Last edited by Damian Ibbotson; 11-26-03 at 12:23.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •