Divide 2 columns of output for a recentage used.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Divide 2 columns of output for a recentage used.
# 1  
Old 01-18-2011
Divide 2 columns of output for a recentage used.

Need some help finishing this one liner.

Code:
nas_pool -l | egrep -v name|grep -v "^$" | awk '{print $4}' | while read  line; do  echo $line ; nas_pool -size $line ; nas_pool -size $line |  egrep -ie 'avail|total' | awk '{print $3}' ; done

OUTPUT:
Code:
clar_r5_performance
id           = 3
name         =  clar_r5_performance
used_mb      = 82973979
avail_mb     = 6268081
total_mb     = 89242060
potential_mb = 3297876

6268081
89242060

clarata_archive
id            = 10
name         = clarata_archive
used_mb      = 51329037
avail_mb     = 3142277
total_mb     =  54471314
potential_mb = 0

3142277
54471314

I am trying to get the % used. so I need to take avail_mb / total_mb * 100 = total % used.
Can you help? Trying to keep it a one liner, if possible...

Thanks!


--
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 01-18-2011 at 12:03 PM.. Reason: code tags, please!
# 2  
Old 01-19-2011
Guess the Output is nas_pool command output.

Code:
nas_pool -l |awk '/avail_mb/{am=$NF}/total_mb/{printf "%f%\n", am/$NF*100}'

7.023685%
5.768682%

# 3  
Old 01-20-2011
output

here is the output of the 2 nas_pool commands...
Code:
 nas_pool -l
id      inuse   acl     name
3       y       0       clar_r5_performance
10      y       0       clarata_archive

nas_pool -l | egrep -v name|grep -v "^$" | awk '{print $4}' | while read  line; do  echo $line ; nas_pool -size $line; done
clar_r5_performance
id           = 3
name         = clar_r5_performance
used_mb      = 83332379
avail_mb     = 5909681
total_mb     = 89242060
potential_mb = 3297876

clarata_archive
id           = 10
name         = clarata_archive
used_mb      = 51329037
avail_mb     = 3142277
total_mb     = 54471314
potential_mb = 0


Last edited by Scott; 01-20-2011 at 12:07 PM.. Reason: Code tags, please...
# 4  
Old 01-21-2011
Code:
nas_pool -l |awk '!/^\$/&&!/name/ {print "nas_pool -size", $4}' | sh > OUTPUT

awk '/avail_mb/{am=$NF}/total_mb/{printf "%f%\n", am/$NF*100}' OUTPUT

This User Gave Thanks to rdcwayx For This Post:
# 5  
Old 01-21-2011
awesome thanks!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print output as columns

Normal grep is not working to get the output. Sample Input: newjob: abc command name: a=b+c newjob: bbc command name: c=r+v newjob:ddc newjob:kkc command name: c=l+g newjob:mdc newjob:ldc newjob:kjc command name: u=dl+g newjob:lkdc newjob:lksdc command name: o=udl+g (6 Replies)
Discussion started by: onesuri
6 Replies

2. Shell Programming and Scripting

append an output file with two columns

Hi All, can you help me with this: grep XXX dir/*.txt|wc -l > newfile.txt - this put the results in the newfile.txt, but I want to add another column in the newfile.txt, string 'YYYYY', separated somehow, which corresponds on the grep results? For example grep will grep XXX dir/*.txt|wc -l >... (5 Replies)
Discussion started by: apenkov
5 Replies

3. Shell Programming and Scripting

Screen Output to Specific Columns

User with moderate experience: I run a script (my addiction is KSH) that reads a file and reports certain parameters back to the user on screen and also piped to a file. The file(s) I read is/are located under different directories, and is usually called the same thing. Sometimes not. For... (3 Replies)
Discussion started by: Brusimm
3 Replies

4. Shell Programming and Scripting

Need to display the output of ls -l selected columns

Hello Friends, Hope you are doing well. I am writing a shell script to find out the log file which are not updated in last 1 hours. I've almost completed the script but need your help in formatting its outputs. Currently, the output of the script is like this(as a flat row): ... (3 Replies)
Discussion started by: singh.chandan18
3 Replies

5. Shell Programming and Scripting

Output columns needs to be aligned

Hi All I'm running a shell script and the output is something like: Col1 Col2 Col3 aaaa aaaaaaa aaaaa bbbbb bbbbb bbbbbb ccc cccccc ccccccc But I require the output to printed as given below: Col1 Col2 Col3 aaaa ... (4 Replies)
Discussion started by: nkamalkishore
4 Replies

6. Shell Programming and Scripting

Formatting output in columns

I have a file which contains data in below format: nbkv28s MgmtReporting -> TradingDesk 1 nbkv28s RMBS -> Credits 178 nbkv28s RMBS -> PassThrough 96 nbkv28s RMBS -> Prepayment 111 nbkv28s RMBS -> RMBSHome 370 nbkv28s RMBS -> TradingStrategy 98 nbkvnze RMBS -> RMBSHome 85 nbkvugn GSF... (3 Replies)
Discussion started by: mohsin.quazi
3 Replies

7. Shell Programming and Scripting

extract columns from command output

I need to extract information (for example, file owner, directory path, etc). However, the code below does not work? What is wrong? find /usr/local/www/apache22/data/dev/chown_test -ls for i in * do cut -f 1,2 "$i" | echo done (3 Replies)
Discussion started by: montana24
3 Replies

8. Shell Programming and Scripting

want to print output if u have rows and columns

U have a file File 1 0.3 0.2 0.4 0.3 0.8 0.11 0.22 0.4 0.23 0.45 0.56 0.78 0.98 0.11 0.32 0.2 0.4 0.45 0.54 0.2 0.33 0.44 0.21 0.22 0.98 0.8 0.2 0.34 0.54 0.98 0.12 0.1 0.22 0.32 0.34 0.89 0.22 File 2 rows columns 3 1 2 3 4 2 5 ... (8 Replies)
Discussion started by: cdfd123
8 Replies

9. Shell Programming and Scripting

Displaying Output in Columns

I'm writing a script to analyze the logs of an smtp relay machine and I'd like the final output to be displayed in columns showing results from the previous day, week, month, and 45 days. The problem I'm running into is that I can't figure out how to display the columns neatly so there is no... (1 Reply)
Discussion started by: jjamd64
1 Replies

10. UNIX for Advanced & Expert Users

abt viewing all the columns in the output as it is..

Hi, How is it possible to get all the columns on the screen while v run a script.. Thr r abt 30 columns.. and whn i run the script the columns in the output r all messed up.. Please help.. Thanks.. RRVARMA (1 Reply)
Discussion started by: RRVARMA
1 Replies
Login or Register to Ask a Question