Sponsored Content
Top Forums Shell Programming and Scripting Need help converting df output to gigabytes Post 302731801 by kuliksco on Thursday 15th of November 2012 08:41:53 PM
Old 11-15-2012
Need help converting df output to gigabytes

I need some help converting the disk space values in kilobytes to gigabytes. I can't use df -h because the report has to be in megabytes for some disk space tracking software the customer is using.

I have been playing around with trying to assign variables I can use outside of awk so I can do the calculations, but am not having much luck.

Can someone help me with this code?


Code:
#!/bin/sh

dat1=`date '+%m/%d/%y'`

hst=`hostname`

df -k | sed -e /^Filesystem/d | awk -v OFS=',' -v dat="$dat1,$hst" ' {print dat,$1,$6,$3,$4 } '

The output right now looks something like this.

11/15/2012 hostname /dev/sda8 / 846516 4931376
11/15/2012 hostname /dev/sda9 /home 212488 1713428
11/15/2012 hostname /dev/sda7 /usr 3855572 5774300
11/15/2012 hostname /dev/sda6 /tmp 761336 8868536
11/15/2012 hostname /dev/sda5 /var 2063256 7566616
11/15/2012 hostname /dev/sda3 /opt 6649916 12617288
11/15/2012 hostname /dev/sda1 /boot 19031 76836

I was just thinking is there any easy way I can just divide by 1024 in the awk portion of the script? It looks like there is something I need to do to force the value to be numeric because the value is always 0.

Last edited by kuliksco; 11-15-2012 at 09:47 PM..
 

9 More Discussions You Might Find Interesting

1. SCO

Converting

I use Sco_Sv 3.2v5.0.5 with parellel conection using dump terminals and i want to convert them to desktop pc. Anybody knows what hardware and other thing that would be involved? (3 Replies)
Discussion started by: seeyou
3 Replies

2. Shell Programming and Scripting

Converting \0 to a \n

Hi - I have seen some similar posts but I am a bit stumped here below is the first line of a 'od -c filename' command. I want to change the \0 to \n 0000000 l s \0 c d - \0 c d . . \0 l s I have tried a sed construct in a script......... sed... (2 Replies)
Discussion started by: ajcannon
2 Replies

3. UNIX for Dummies Questions & Answers

Converting gettimeoftheday output to string

Hi .. is there a way i can retrieve the output of gettimeoftheday in a string (1 Reply)
Discussion started by: p_aishwarya
1 Replies

4. Shell Programming and Scripting

Converting to columnar output

Hi All, I need some help in script or awk to create a textfile. I have a directory where two subdirectories exists say A and B. Now I need to write a ".txt" file with well arranged(space wraped) three columns in it with the data as follows: 1st column:Serial number(which will increment... (4 Replies)
Discussion started by: Sreejith_VK
4 Replies

5. AIX

Converting Blocks to megabytes and gigabytes.

Sorry for the simple question. I am new to Unix and Unix AIX. I increased a file system the other day but cheated and used a conversion calculator. Could you good people tell me the best way to increase a file system that is in 512 byte blocks. Say the file system is 100mb and I wanted... (5 Replies)
Discussion started by: jfd7000
5 Replies

6. Shell Programming and Scripting

Converting line output to column based output

Hi Guys, I am trying to convert a file which has a row based output to a column based output. My original file looks like this: 1 2 3 4 5 6 1 2 3 1 2 3 (8 Replies)
Discussion started by: npatwardhan
8 Replies

7. Ubuntu

Converting Impress output to DVD video

I have a need to convert 'Impress' presentations to DVD video format whilst retaining the original presentation in situ. Copying the individual slides and modifying size etc. in Gimp and then importing them into 'Openshot' is both long winded and the loss of quality is significant. Can anybody... (14 Replies)
Discussion started by: Royalist
14 Replies

8. UNIX for Dummies Questions & Answers

Converting txt output to rows and columns and send report via mail.

Hi All, I would like to send below output in a tabular column ( xml or excel ) and send a mail. vinay unix anil sql vamsee java request to suggest a solution. (1 Reply)
Discussion started by: Girish19
1 Replies

9. Shell Programming and Scripting

Need Help in converting

I have Excel file with the below three columns, i need your expertise in converting this to .csv file delimiter "|" Excel - Serial Number Serial Name Serial Brand 111 test sample 123 test2 sample1 134 ... (9 Replies)
Discussion started by: kiran_hp
9 Replies
FS_LISTQUOTA(1) 					       AFS Command Reference						   FS_LISTQUOTA(1)

NAME
fs_listquota - Displays quota information for a volume SYNOPSIS
fs listquota [-path <dir/file path>+] [-human] [-help] fs listq [-p <dir/file path>+] [-hu] [-he] fs lq [-p <dir/file path>+] [-hu] [-he] DESCRIPTION
The fs listquota command displays information about the volume containing each specified directory or file (its name, quota, and amount of disk space used), along with an indicator of the percentage of space used on the host partition. To display more information about the host partition, use the fs examine command. To set volume quota, use the fs setquota or fs setvol command. CAUTIONS
Currently, the maximum size of a volume is 2 terabytes (2^31 bytes). OPTIONS
-path <dir/file path>+ Names a file or directory that resides in the volume about which to produce output. Partial pathnames are interpreted relative to the current working directory, which is also the default value if this argument is omitted. -human Print space in a "human-readable" format. Instead of always printing space in kilobytes, show disk space in kilobytes, megabytes, gigabytes, terabytes, or petabytes, as appropriate. -help Prints the online help for this command. All other valid options are ignored. OUTPUT
The output displays information about the volume that houses each specified directory or file, in a tabular format that uses the following headers: Volume Name The name of the volume. Quota The volume's quota in kilobytes, or the string "no limit" to indicate an unlimited quota. Used The amount of space used. If -human is not specified, this value is in kilobytes. % Used The percentage of the volume's quota that is used (the "Used" statistic divided by the "Quota" statistic, times 100). Partition The percentage of space used on the partition that houses the volume. Although not directly related to how much of the user's quota is used, it is reported because a full partition can cause writing of data back to the volume to fail even when the volume has not reached its quota. EXAMPLES
The following example shows the output for the volume "user.smith": % fs listquota -path /afs/abc.com/usr/smith Volume Name Quota Used % Used Partition user.smith 15000 5071 34% 86% PRIVILEGE REQUIRED
The issuer must have the "r" (read) permission on the ACL of the root directory of the volume that houses the file or directory named by the -path argument, and "l" (list) permission on the ACL of each directory that precedes it in the pathname. SEE ALSO
fs_diskfree(1), fs_examine(1), fs_quota(1), fs_setquota(1), fs_setvol(1) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2012-03-26 FS_LISTQUOTA(1)
All times are GMT -4. The time now is 11:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy