Adding and then separating the output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding and then separating the output
# 8  
Old 10-20-2011
Quote:
Originally Posted by bombcan
...
Why do you have the other amounts of GB on the far right. I don't have that in my file and don't need them.
Fair enough.

Code:
$
$ perl -ane 'chomp; $F[1]=~s/GB//; $s+=$F[1]; $m=int($s/1000);
             $enl=$m>$p ? "\n":""; $bnl=$m>($p+1) ? "\n":"";
             printf("%s%-40s%s\n",$bnl,$_,$enl); $p=$m
            ' f34
/vol/vol0 4GB
/vol/nonprod00 682GB
/vol/prod00 3GB
/vol/nasp_archive 201GB
/vol/nasp_iface 92GB
/vol/nasp_bsi 0GB
/vol/nasp_vertex 0GB
/vol/nasp_sapmnt_mp2 1GB
/vol/nasp_sapmnt_prd 52GB
 
/vol/nasp_sapmnt_srp 1GB
/vol/nasp_smd 1GB
/vol/nasp_ccms 0GB
/vol/nasp_saptrans_erp 45GB
/vol/nasp_saptrans_mip 4GB
/vol/nasp_saptrans_ndp 25GB
/vol/nasp_saptrans_srm 7GB
/vol/nasp_sapmnt_ndp 2GB
/vol/sharedump 0GB
/vol/arcsight 506GB
/vol/sap_depot 355GB
/vol/trp_sapmnt_sq1 2GB
/vol/trp_sapmnt_sq2 2GB
/vol/cnfo_prd 0GB
/vol/ztrap 0GB
/vol/hpux_cnprd 47GB
 
/vol/cn_prd 29GB
/vol/fixes 0GB
 
/vol/prod04 3061GB
 
$
$

In case you were wondering what the number to the far right was - it was the running sum (or cumulative sum) of the volume sizes. A newline is printed as soon as it crosses a TB boundary. Sorry, I misread your original question.

tyler_durden
This User Gave Thanks to durden_tyler For This Post:
# 9  
Old 10-20-2011
Ahh great thanks much appreciated
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Separating output after final character

I'm trying to write a script that will email the contents of my Application folder to me. cd /Applications ListApps=$(ls) echo $ListApps | mail -s "Application Check" myself@myemail.com This sends it in a paragraphed block i.e: Adobe Acrobat Reader.app App Store.app Atom.app... (4 Replies)
Discussion started by: $shell_Learner
4 Replies

2. Shell Programming and Scripting

Adding hostname on the output

// AIX 6.1 pcmpath query device |awk 'BEGIN{print "TYPE\tDEVICE NAME\tSERIAL\tSIZE"} /DEVICE/ {disk=$5 printf "%s\t", $7 printf "%s\t", disk getline; printf "%s\t", substr($2, length($2)-3) ("bootinfo -s "... (2 Replies)
Discussion started by: Daniel Gate
2 Replies

3. Shell Programming and Scripting

adding file extensions to split output files

Hello, I've searched this forum and others for a solution to my problem but nothing seems just right, I'm hoping I can get some help (seems like this should be easy, and I apologize if I've missed something on the forum): I have several large .fastq DNA sequence files (~20million reads,... (2 Replies)
Discussion started by: ljk
2 Replies

4. Shell Programming and Scripting

adding data in input file if 2nd script output SUCCESS

Hi All, how can i edit my original data and add more data if my 2nd script outputs SUCESS? ex. input file: 1.txt nik,is,the 1script.sh if 2ndscript.sh output SUCCESS then i'm going to edit my input file and add data best,pogi.. sample outputdata. nik,is,the,best,pogi 2ndscript.sh... (3 Replies)
Discussion started by: nikki1200
3 Replies

5. Shell Programming and Scripting

separating folders

I have folder like main. inside main folder there are subfolders & files like main1 main2 main3, file1, file2, file3. I want folders main1 & main2, file1, file2 from main folder. copy them into new folder. Please suggest me how to do it. I am new to shell programming (2 Replies)
Discussion started by: ypremcha
2 Replies

6. Shell Programming and Scripting

Adding Text To |bc Output

Hello. I have this.. $ echo '2+2' | bc 4 But I want to output it as 4 MB So, can I achieve that through one single command line? Thank you. (7 Replies)
Discussion started by: aimy
7 Replies

7. Shell Programming and Scripting

adding another field to SED output

Dear experts, I have a file called "check" with contents like below i used the sed command like below to get the value of "success" and "failed" only My question is how can i get the value to include the time "03:15", so that i can get a value such as below : - Appreciate... (4 Replies)
Discussion started by: aismann
4 Replies

8. Shell Programming and Scripting

adding order number in the output file

Hello, I have a list of all order number like below: maryu01001 johnm00003 peter02234 catmy66751 For the above, all number must in 5 digits and I need to add one into the number and output a new list like below: maryu01002 johnm00004 peter02235 catmy66752 How can write a... (20 Replies)
Discussion started by: happyv
20 Replies

9. Shell Programming and Scripting

separating fields

Hi, i have a file as follows: jonathan:bonus1,bonus2 gerald:bonus1 patrick:bonus1,bonus2 My desired output is jonathan:bonus1 jonathan:bonus2 gerald:bonus1 patrick:bonus1 patrick:bonus2 my current code is cat $F | awk -F"" how should i continue the code? Can i do something... (5 Replies)
Discussion started by: new2ss
5 Replies

10. Programming

separating commands

hey there well i have a small problem with my code. when for example : " /bin/sleep 10 & ls -l mila > xyz " is entered, the program is supposed to separate the two commands 1) /bin/sleep 10 & and 2) ls -l mila > xyz. im not sure of how to achieve this. my current program stores both commands... (2 Replies)
Discussion started by: mile1982
2 Replies
Login or Register to Ask a Question