Results 1 to 2 of 2

Thread: AWK Scripting

  1. #1
    Join Date
    Nov 2003
    Location
    Australia
    Posts
    2

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

  2. #2
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    780

    Re: AWK Scripting

    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.

Posting Permissions

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