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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sum output 2

Status
Not open for further replies.

ozi403

Technical User
Apr 29, 2002
54
TR
How can I get total sum of output below in continueous command line?

# grep ngahdsrv: deneme | grep -v savegrp: | grep -v "*" | cut -d, -f2 | awk '{ print $1 }'
17
251
944
1129
753
#

thanks all.
 
> awk '{ print $1 }'
Replace this with
Code:
awk '{ sum += $1 }
END { print sum }'

--
 
Why not just use awk, like this ?
Code:
awk -F, '
/savegrp:/{next}
/\*/{next}
/ngahdsrv:/{sum+=$2}
END{print sum}
' deneme

Hope This Help
PH.
 
Hi,

All these are helpful. And now I have a new case that's I want to multiply these numbers with 1000.Can you help me?
 
Like this ?
Code:
awk -F, '
/savegrp:/{next}
/\*/{next}
/ngahdsrv:/{sum+=$2}
END{print sum*1000}
' deneme

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top