Sep 22, 2009 #1 brk6971 Technical User Aug 10, 2007 9 US Have a script that produces the sum of a column of numbers: cat file |awk '{ sum += $1 } END { print sum }' >sum Now I want to divide the sum by 1024 and have the output print on the screen.
Have a script that produces the sum of a column of numbers: cat file |awk '{ sum += $1 } END { print sum }' >sum Now I want to divide the sum by 1024 and have the output print on the screen.
Sep 22, 2009 #2 Annihilannic MIS Jun 22, 2000 6,317 AU No need for cat there. Why not just repeat the command, adjusted slightly, unless of course it's a large input file: Code: awk '{ sum += $1 } END { print sum/1024 }' file Annihilannic. Upvote 0 Downvote
No need for cat there. Why not just repeat the command, adjusted slightly, unless of course it's a large input file: Code: awk '{ sum += $1 } END { print sum/1024 }' file Annihilannic.
Sep 24, 2009 Thread starter #3 brk6971 Technical User Aug 10, 2007 9 US Thanks that worked. The file was not that large. Upvote 0 Downvote