Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax to divide a number in a script

Status
Not open for further replies.

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.

 
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.
 
Thanks that worked. The file was not that large.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top