From owner-freebsd-questions@FreeBSD.ORG Sat Dec 15 06:37:25 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5494316A417 for ; Sat, 15 Dec 2007 06:37:25 +0000 (UTC) (envelope-from patrick_dkt@yahoo.com.hk) Received: from web54307.mail.re2.yahoo.com (web54307.mail.re2.yahoo.com [206.190.49.117]) by mx1.freebsd.org (Postfix) with SMTP id EF89D13C45A for ; Sat, 15 Dec 2007 06:37:24 +0000 (UTC) (envelope-from patrick_dkt@yahoo.com.hk) Received: (qmail 98888 invoked by uid 60001); 15 Dec 2007 06:37:23 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.hk; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=KAYlJDSW7/Ai/b2xnWccUfidqPNx+0Q8STLtQB3Tuyaq3es9GPX/S60im/UW7aEU4BwPoOXGv6WIocDQduJBm0lJNelkZWv1+20wuCG9sEN3aMYKzd4Qq5lM4JtgR7C4fIGzScPxvec8W0ZEaCR8igrKvTGwwkZiQOp4+zxXc3M=; X-YMail-OSG: I5gtn3wVM1kEv3Qa3uJGm79nOpmS5iUIh4ZQcoSzWEgYpQKH1iv78oCfLY_asfFSLUT5hld2RzdqK_EviMNNl3QGNM634nDgi7G0zaOgfW4ENSgj7rMy_WR_LXgsjhxV Received: from [61.15.61.52] by web54307.mail.re2.yahoo.com via HTTP; Fri, 14 Dec 2007 22:37:23 PST Date: Fri, 14 Dec 2007 22:37:23 -0800 (PST) From: Patrick Dung To: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <885271.78579.qm@web54307.mail.re2.yahoo.com> Subject: Bash script to find out the summary of user memory usage [not working] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Dec 2007 06:37:25 -0000 Hello, any idea about why below script is not working? The final sum is empty.. #!/usr/local/bin/bash for user in `ps -A -o user | sort | uniq | tail +2` do echo "user: $user" ps aux -U $user | tail +2 | while read line do mem=`echo $line | awk {'print $4'}` echo "mem: $mem" TMPSUMMEM=`awk -v x=$mem -v y=$TMPSUMMEM 'BEGIN{printf "%.2f\n",x+y}'` echo "summem: $TMPSUMMEM" done echo "finalsummem: $SUMMEM" donefreebsd-questions@freebsd.org.hk ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping