-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sun, 7 Apr 2002, vincent li wrote: >i need to write a short shell script to get the >available memory percentage,for example: if i get >available memory 2033680, and total memory 2555848, >how could i change these two data into percentage? > >if i excute `expr 2033680 / 2555848` ,result is 0, pls >tell me how to get the percentage result i want..
Use the GNU calculator, bc: echo 'scale=20;2033680/2555848*100' | bc If you only need the first few digits, you can do this: export BC_LINE_LENGTH=7 echo 'scale=20;2033680/2555848*100' | bc | head -n 1 | cut -f 1 -d '\' Tony - -- Anthony E. Greene <mailto:[EMAIL PROTECTED]%3E> OpenPGP Key: 0x6C94239D/7B3D BD7D 7D91 1B44 BA26 C484 A42A 60DD 6C94 239D AOL/Yahoo Chat: TonyG05 HomePage: <http://www.pobox.com/~agreene/> Linux. The choice of a GNU generation <http://www.linux.org/> -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Anthony E. Greene <[EMAIL PROTECTED]> 0x6C94239D iD8DBQE8sUYkpCpg3WyUI50RAtEmAJ0XfiVO8VRI86whPYvg/IrhbX9deQCffc4r bqn1IQPwjpoyJfOQJLY9/E8= =fcfR -----END PGP SIGNATURE----- _______________________________________________ Redhat-list mailing list [EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-list