🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1538

Re: shell / awk question

#1538
From: BURNS
Date: Fri, 19 Oct 1990 07:51
75 lines
2888 bytes
in article <4057@ruuinf.cs.ruu.nl>, emwessel@praxis.cs.ruu.nl (Eric van Wessel) says:
> quota | awk 'BEGIN { FS=" " } { quot=$2 }
> 	     END { printf "%d\n",quot } '
> 				  ^^
> 				  How to make quot known here ? [etc]

The following is a rework of your script. Since my quota(1) reports in the
format:

Your disk usage is approximately       788,480 bytes;
your disk quota is                   2,048,000 bytes.

and my du reports in 1k block sizes, there are minor cosmetic changes,
besides the eval and proper quoting tricks. If your quota(1) supports the
'-qv' option (see man excerpts following script), the first assignment can
be replaced w/the second commented one.

eval QUOTA=`quota | awk 'BEGIN { FS=" " } { quot=$5 }
	     END { print quot }' | sed 's/,//g'`
#eval QUOTA=`quota -qv`
du -s $HOME |
awk 'BEGIN { FS=" " } { printf "\nDiskspace\n";
			printf "---------\n";
			used=$1;
			free='$QUOTA'/1024-used }
     END   { printf "Used : %d kb. (%d%%)\n",used,used*100/('$QUOTA'/1024) ;
	     if (free>=0)
	       printf "Free : %d kb.\n\n",free
	     else printf "Too much : %d kb.\n\n",-free } '

QUOTA(1)         Georgia Institute of Technology         QUOTA(1)



NAME
     quota - display PRISM disk storage usage and maximum limit

SYNOPSIS
     quota [ -q ] [ -u ] [ -v ]

DESCRIPTION
     [...]
OPTIONS
     -q   Display only maximum limit.

     -u   Display only usage.

     -v   Display usage and/or maximum limit value(s) without
          title(s) and without comma formatting the numeric
          value(s).  This is useful for manipulating the value(s)
          in a shell script.

     By default, display usage and then maximum limit, both with
     titles and comma formatting the numeric values.

EXAMPLES
     Here's how to display your disk storage usage and maximum
     limit:
          {hydra:gtuser:22} quota
          Your disk usage is approximately     1,237,792 bytes;
          your disk quota is                   2,048,000 bytes.
          {hydra:gtuser:23}

     Here's how to get your maximum limit into a shell variable
     (assuming your shell is ksh):
          {hydra:gtuser:24} quota=`quota -qv`
          {hydra:gtuser:25} echo $quota
          2048000
          {hydra:gtuser:26}
     [...]
-- 
BURNS,JIM
Georgia Institute of Technology, Box 30178, Atlanta Georgia, 30332
uucp:	  ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt0178a
Internet: gt0178a@prism.gatech.edu
Technical Details
Message-ID: <15478@hydra.gatech.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!olivea!samsung!emory!gatech!prism!gt0178a
References: <4057@ruuinf.cs.ruu.nl>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!olivea!samsung!emory!gatech!prism!gt0178a
From: gt0178a@prism.gatech.EDU (BURNS)
Newsgroups: comp.unix.shell
Subject: Re: shell / awk   question
Message-ID: <15478@hydra.gatech.EDU>
Date: 19 Oct 90 07:51:03 GMT
References: <4057@ruuinf.cs.ruu.nl>
Organization: Georgia Institute of Technology
Lines: 75