add up the used space..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting add up the used space..
# 1  
Old 01-31-2012
add up the used space..

I am trying to write a script to add up the used space on hp unix.

Below is the script what i am trying, but not getting the desired output.

can somebody guide me.


Code:
#!/bin/ksh
t1=bdf |grep /u01|awk '{print $2}'
t2=bdf |grep /u02|awk '{print $2}'
t3=bdf |grep /u03|awk '{print $2}'
t4=bdf |grep /u04|awk '{print $2}'
t='expr $t1+ expr $t2+expr $t3+ expr $t4'
echo $t

Moderator's Comments:
Mod Comment Please use [CODE][/CODE] tags where appropriate, thank you

Last edited by vbe; 01-31-2012 at 04:14 AM..
# 2  
Old 01-31-2012
Code:
t1=`bdf |grep /u01|awk '{print $2}'`
#Apply the above for all other t values
t=`expr $t1 + $t2 + $t3 + $t4`

This User Gave Thanks to itkamaraj For This Post:
# 3  
Old 01-31-2012
All in one
Code:
t=$(bdf |awk '/u0[1234]/{sum+=$2}END{print sum}' )

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Ubuntu

Unable to add space

I have / root directory has file system /dev/sda1 with 19G space I want to add some more space to /home directory but unable to do it while running below command getting below message $sudo mkfs -t ext4 /dev/sda2 mke2fs 1.42.9 (4-Feb-2014) mkfs.ext4: inode_size (128) * inodes_count (0) too... (4 Replies)
Discussion started by: megh
4 Replies

2. Shell Programming and Scripting

awk to add space between text

I am trying to use awk to add a space in a string of text. My awk is close but does not produce the desured output. Thank you :). input washington aveLansing, MI washington streetLansing, MI Desired output washington ave Lansing, MI washington street Lansing, MI awk -F"\t"... (9 Replies)
Discussion started by: cmccabe
9 Replies

3. Shell Programming and Scripting

sed add space X times

Pattern: Mary walks at the park every day with her children sed 's/$/ /' will make it add 1 space at the end (trailing) I want to add X ($VARIABLE) number of spaces (which comes from RANDOM) i.e. VARIABLE='14' then it will do: sed 's/$/ /' = 14 spaces added at the... (10 Replies)
Discussion started by: holyearth
10 Replies

4. Shell Programming and Scripting

Add white space

hi guys how can i add spacein file name with sed if strings have no space around dash input 19-20 ( 18-19 ) ABC-EFG output after add white space 19 - 20 (18 - 19 ) ABC - EFG thx in advance (2 Replies)
Discussion started by: mhs
2 Replies

5. Shell Programming and Scripting

add only one space after each word in a string

hi, I have this string: a="abc def ghi jkl mno pqr" how can I display this to: abc def ghi jkl mno pqr # only one space each (14 Replies)
Discussion started by: h0ujun
14 Replies

6. Shell Programming and Scripting

Add a space at end of file

Hi I guess this is very simple.... I want to add a space at the last line in a file. The space has to be the last charachter on the last line, not at a new line. Anyone ?? (7 Replies)
Discussion started by: disel
7 Replies

7. Linux

add space

Hello ! I get this when I type df -m # df -m Filesystem 1M-blocks Used Available Use% Mounted on /dev/ida/c0d0p2 23547 22197 155 100% / /dev/ida/c0d0p1 97 10 83 10% /boot none 1934 0 1934 0%... (1 Reply)
Discussion started by: lo-lp-kl
1 Replies

8. UNIX for Advanced & Expert Users

Add new lines with a space in beginning

Hi file1.txt contains GigabitEthernet1/1 GigabitEthernet1/2 GigabitEthernet2/2 GigabitEthernet2/4 GigabitEthernet2/14 GigabitEthernet2/16 can anyone show me how to modify it as below. there is a space at the beginning of the next two lines . ie 'no shut' and 'switch..' !... (8 Replies)
Discussion started by: Aejaz
8 Replies

9. HP-UX

How to add space in between columns in VI editor

Hi, I am trying to add space after 3rd and 6th column for editing a file in special format. How should I achieve in VI?. So, is it possible to do in it in sed ? thanks vipa (1 Reply)
Discussion started by: vipas
1 Replies

10. UNIX for Dummies Questions & Answers

add space to filesystem in solaris

I need step-by-step on how to add more space to /apps in solaris. Currently df -hk: /dev/md/dsk/d40 15G 13G 1.6G 90% /app How much can I expand and how? Thanks in advance. (2 Replies)
Discussion started by: simt
2 Replies
Login or Register to Ask a Question