Sponsored Content
Top Forums Shell Programming and Scripting Calculate total space, total used space and total free space in filesystem names matching keyword Post 302374494 by bigben1220 on Tuesday 24th of November 2009 04:34:04 PM
Old 11-24-2009
Calculate total space, total used space and total free space in filesystem names matching keyword

Good afternoon! Im new at scripting and Im trying to write a script to
calculate total space, total used space and total free space in filesystem names matching a keyword (in this one we will use keyword virginia). Please dont be mean or harsh, like I said Im new and trying my best. Scripting doesnt come easy for me.

So this is what Im trying to write specifically:

- Calculate the sum of total space, used space for all matching filesystems
- Display "Total Space = xx " ; "Used Space = yy"; "Free space = zz"




Code:
find / -name virginia 2>/dev/null
read ans_2
bdf * [ ans_2 ]
awk '{ s += $1 } END { print "Total Space: ", s, " Used Space: ", s/NR, " Free Space: ", NR }

Thanks in advance for any help!
BigBen

Last edited by bigben1220; 11-24-2009 at 06:15 PM.. Reason: code tags, please...
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

df+du=Total space allocated(for a file system)

Hi All, Will df+du=Total space allocted for a file system?? Is the above correct. Please correct me If iam wrong. In one my programs the above is not happening. Please help me out. Many thanks. Regards, Manas (2 Replies)
Discussion started by: manas6
2 Replies

2. AIX

used PPs not match the total disk space showed by df

Hi, I see from lsvg the total used PPs is 1050 (67200 megabytes), but when I check the disk space with df command I can only see 31G total space, can somebody tell how this come? Thanks! Victor # lsvg rootvg # lsvg rootvg VOLUME GROUP: rootvg VG IDENTIFIER: ... (2 Replies)
Discussion started by: victorcheung
2 Replies

3. Red Hat

Total space Determination

Hi experts, # df -h Filesystem Size Used Avail Use% Mounted on /dev/hda9 3.8G 1.7G 2.0G 46% / none 369M 0 369M 0% /dev/shm /dev/hda10 2.0G 33M 1.8G 2% /tmp /dev/hda12 1.4G 1.2G 260M 82% /usr I used df -h... (3 Replies)
Discussion started by: William1482
3 Replies

4. Solaris

swap size, total disk space

Hi experts, In my solaris system when i run the command df -h i got the below response.I have some confusion which i want to share with you guys.1)there are two SWAP file system shows are they same or different?2)if i want to count the total disk space should i take both the swap space or only... (2 Replies)
Discussion started by: rafiassam
2 Replies

5. Solaris

command to get the total disk space (available + free)

is there a command to get the total disk space (available + free) on the solaris server ? thanks (3 Replies)
Discussion started by: sudhiroracle
3 Replies

6. Emergency UNIX and Linux Support

Calculating total space in GB for all files with typical pattern

Hi Experts, In a particular dir, I have many files *AJAY*. How can I get total size of all such files. I tried du -hs *AJAY* but it gave me individual size of all files. All I require is summation of all. Thanks, Ajay (4 Replies)
Discussion started by: ajaypatil_am
4 Replies

7. Solaris

Problem in getting total Disk space using iostat -En command

Hi Everyone, I try to calculate the total hard disk space of a solaris machine using iostat -En command. Iterating the output and summing up all the number present near the Size: will give the exact size of the harddisk. But it is not working for a machine. This command works in many flavors... (2 Replies)
Discussion started by: prasankn
2 Replies

8. Red Hat

Total storage space and Serial number

Hi, Could you please tell me the commands to find Total storage space and Serial number of Linux server. OS -- Red Hat Enterprise Linux Server release 6.6 (Santiago) This is 2 node cluster. Regards, Maddy (1 Reply)
Discussion started by: Maddy123
1 Replies

9. Shell Programming and Scripting

Calculate total memory using free -m

Hi I am trying to calculate memory used by Linux System free -m total used free shared buffers cached Mem: 32109 31010 1099 0 3600 7287 -/+ buffers/cache: 20121 11987 Swap: 10239 1282 8957 Now according to my requirement Im calculating memory using below cmd free -m | awk 'NR==3{printf... (2 Replies)
Discussion started by: sam@sam
2 Replies
MATRIX(9.2)															       MATRIX(9.2)

NAME
ident, matmul, matmulr, determinant, adjoint, invertmat, xformpoint, xformpointd, xformplane, pushmat, popmat, rot, qrot, scale, move, xform, ixform, persp, look, viewport - Geometric transformations SYNOPSIS
#include <libg.h> #include <geometry.h> void ident(Matrix m) void matmul(Matrix a, Matrix b) void matmulr(Matrix a, Matrix b) double determinant(Matrix m) void adjoint(Matrix m, Matrix madj) double invertmat(Matrix m, Matrix inv) Point3 xformpoint(Point3 p, Space *to, Space *from) Point3 xformpointd(Point3 p, Space *to, Space *from) Point3 xformplane(Point3 p, Space *to, Space *from) Space *pushmat(Space *t) Space *popmat(Space *t) void rot(Space *t, double theta, int axis) void qrot(Space *t, Quaternion q) void scale(Space *t, double x, double y, double z) void move(Space *t, double x, double y, double z) void xform(Space *t, Matrix m) void ixform(Space *t, Matrix m, Matrix inv) int persp(Space *t, double fov, double n, double f) void look(Space *t, Point3 eye, Point3 look, Point3 up) void viewport(Space *t, Rectangle r, double aspect) DESCRIPTION
These routines manipulate 3-space affine and projective transformations, represented as 4x4 matrices, thus: typedef double Matrix[4][4]; Ident stores an identity matrix in its argument. Matmul stores axb in a. Matmulr stores bxa in b. Determinant returns the determinant of matrix m. Adjoint stores the adjoint (matrix of cofactors) of m in madj. Invertmat stores the inverse of matrix m in minv, returning m's determinant. Should m be singular (determinant zero), invertmat stores its adjoint in minv. The rest of the routines described here manipulate Spaces and transform Point3s. A Point3 is a point in three-space, represented by its homogeneous coordinates: typedef struct Point3 Point3; struct Point3{ double x, y, z, w; }; The homogeneous coordinates (x, y, z, w) represent the Euclidean point (x/w, y/w, z/w) if w!=0, and a ``point at infinity'' if w=0. A Space is just a data structure describing a coordinate system: typedef struct Space Space; struct Space{ Matrix t; Matrix tinv; Space *next; }; It contains a pair of transformation matrices and a pointer to the Space's parent. The matrices transform points to and from the ``root coordinate system,'' which is represented by a null Space pointer. Pushmat creates a new Space. Its argument is a pointer to the parent space. Its result is a newly allocated copy of the parent, but with its next pointer pointing at the parent. Popmat discards the Space that is its argument, returning a pointer to the stack. Nominally, these two functions define a stack of transformations, but pushmat can be called multiple times on the same Space multiple times, creating a transformation tree. Xformpoint and Xformpointd both transform points from the Space pointed to by from to the space pointed to by to. Either pointer may be null, indicating the root coordinate system. The difference between the two functions is that xformpointd divides x, y, z, and w by w, if w!=0, making (x, y, z) the Euclidean coordinates of the point. Xformplane transforms planes or normal vectors. A plane is specified by the coefficients (a, b, c, d) of its implicit equation ax+by+cz+d=0. Since this representation is dual to the homogeneous representation of points, libgeometry represents planes by Point3 structures, with (a, b, c, d) stored in (x, y, z, w). The remaining functions transform the coordinate system represented by a Space. Their Space * argument must be non-null -- you can't mod- ify the root Space. Rot rotates by angle theta (in radians) about the given axis, which must be one of XAXIS, YAXIS or ZAXIS. Qrot trans- forms by a rotation about an arbitrary axis, specified by Quaternion q. Scale scales the coordinate system by the given scale factors in the directions of the three axes. Move translates by the given displace- ment in the three axial directions. Xform transforms the coordinate system by the given Matrix. If the matrix's inverse is known a priori, calling ixform will save the work of recomputing it. Persp does a perspective transformation. The transformation maps the frustum with apex at the origin, central axis down the positive y axis, and apex angle fov and clipping planes y=n and y=f into the double-unit cube. The plane y=n maps to y'=-1, y=f maps to y'=1. Look does a view-pointing transformation. The eye point is moved to the origin. The line through the eye and look points is aligned with the y axis, and the plane containing the eye, look and up points is rotated into the x-y plane. Viewport maps the unit-cube window into the given screen viewport. The viewport rectangle r has r.min at the top left-hand corner, and r.max just outside the lower right-hand corner. Argument aspect is the aspect ratio (dx/dy) of the viewport's pixels (not of the whole viewport). The whole window is transformed to fit centered inside the viewport with equal slop on either top and bottom or left and right, depending on the viewport's aspect ratio. The window is viewed down the y axis, with x to the left and z up. The viewport has x increas- ing to the right and y increasing down. The window's y coordinates are mapped, unchanged, into the viewport's z coordinates. SOURCE
/sys/src/libgeometry/matrix.c MATRIX(9.2)
All times are GMT -4. The time now is 08:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy