report negative value from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting report negative value from file
# 1  
Old 10-21-2008
report negative value from file

Hello,

I need help to write a script to do the following:

1) read the following file vol_check.out
2) report any negative value with host and volume name

vol_check.out file contents:

---------------------------------- prod_filer1 ---------------------------------
--------------------------------------------------------------------------------
------------------------------------ vol_db1 ----------------------------------
Total size = 1520435200KB == 1450 GB
Space Used by Quotas = 1343225856KB == 1281 GB
Space Used = 1495269376KB == 1550 GB
Free Space = 25165824KB == -100 GB
------------------------------------ vol_db2 ----------------------------------
Total size = 1205862400KB == 1150 GB
Space Used by Quotas = 1038551040KB == 990.439 GB
Space Used = 1159137280KB == 1105.44 GB
Free Space = 46725120KB == 44.5605 GB
------------------------------------ vol_db3 ----------------------------------
Total size = 1268776960KB == 1210 GB
Space Used by Quotas = 1116733440KB == 1065 GB
Space Used = 1243611136KB == 1186 GB
Free Space = 25165824KB == 24 GB

------------------------------------ vol_db4 ----------------------------------

Total size = 1205862400KB == 1150 GB
Space Used by Quotas = 1106247680KB == 1055 GB
Space Used = 1226833920KB == 1170 GB
Free Space = -20971520KB == -20 GB
------------------------------------ vol_db5 ----------------------------------
Total size = 1415577600KB == 1350 GB
Space Used by Quotas = 1268782080KB == 1210 GB
Space Used = 1410339840KB == 1345 GB
Free Space = 5237760KB == 4.99512 GB
------------------------------------ vol_db6 ----------------------------------
Total size = 2147483648KB == 2000 GB
Space Used by Quotas = 1385568896KB == 1321.38 GB
Space Used = 1815065624KB == 2200 GB
Free Space = 332418024KB == -200 GB


-------------------------- prod_filer2 ---------------------------------
--------------------------------------------------------------------------------
------------------------------------ db_vol16 ----------------------------------

Total size = 12771655680KB == 12180 GB
Space Used by Quotas = 10763632640KB == 10265 GB
Space Used = 12040798208KB == 11483 GB
Free Space = 730857472KB == 697 GB

------------------------------------ db_vol17 ----------------------------------

Total size = 13421772800KB == 12800 GB
Space Used by Quotas = 11732516864KB == 11189 GB
Space Used = 13074694144KB == 12469 GB
Free Space = 347078656KB == 331 GB
------------------------------------ db_vol19 ----------------------------------
Total size = 8912896000KB == 8500 GB
Space Used by Quotas = 7916748800KB == 7550 GB
Space Used = 8808038400KB == 8400 GB
Free Space = 104857600KB == 100 GB
----------------------------------------------------------------------------

------------------------------ prod_filer3 ---------------------------------

------------------------------------ vol_data40 ----------------------------------
Total size = 12777947136KB == 12000 GB
Space Used by Quotas = 11607736320KB == 11070 GB
Space Used = 12502192616KB == 13500 GB
Free Space = 275754520KB == -1500 GB

------------------------------------ vol_data45 ----------------------------------
Total size = 13197377536KB == 12586 GB
Space Used by Quotas = 12244269056KB == 11677 GB
Space Used = 13168085480KB == 12558.1 GB
Free Space = 29292056KB == 27.9351 GB

------------------------------------ vol_data46 ----------------------------------
Total size = 8912896000KB == 8500 GB
Space Used by Quotas = 7415529472KB == 7072 GB
Space Used = 8039432192KB == 7667 GB
Free Space = 873463808KB == 833 GB
----------------------------------------------------------------------------
---------------------------- prod_filer4 ---------------------------------
--------------------------------------------------------------------------------


------------------------------- vol_data1 ----------------------------------
Total size = 12635340800KB == 12050 GB
Space Used by Quotas = 11102322688KB == 10588 GB
Space Used = 12113149952KB == 11552 GB
Free Space = 522190848KB == 498 GB

-------------------------------- vol_data2 ----------------------------------
Total size = 12635340800KB == 12050 GB
Space Used by Quotas = 9924771840KB == 9465 GB
Space Used = 10935599104KB == 10429 GB
Free Space = 1699741696KB == 1621 GB

---------------------------------- vol_data3 ----------------------------------
Total size = 8912896000KB == 8500 GB
Space Used by Quotas = 5986320384KB == 5709 GB
Space Used = 6699352064KB == 6389 GB
Free Space = 2213543936KB == 2111 GB
----------------------------------------------------------------------------


example: reading the vol_check.out file the script should report the following:

Please check: vol_db1 on prod_filer1 is larger than expected
Please check: vol_db4 on prod_filer1 is larger than expected
Please check: vol_db6 on prod_filer1 is larger than expected
Please check: vol_data40 on prod_filer3 is larger than expected

Thanks for your help:
# 2  
Old 10-21-2008
Code:
nawk '{
if(index($0,"prod")!=0)
{
	gsub(/-/,"",$0)
	prod=$0
}
if(index($0,"vol")!=0)
{
	gsub(/-/,"",$0)
	vol=$0
}
if($1=="Free" && $6<0)
	print "Please check: "vol" on "prod" is larger than expected"
}' filename

# 3  
Old 10-21-2008
awk is likely to be your friend here.

What have you tried so far / where is your code/logic needing work ?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Splitting a file based on negative and positive numbers

I have a file that is pipe delimited and in Column F they have number values, both positive and negative. I need to take the one file I am starting with and split it into two separate files based on negative and positive numbers. What is the command to do so? And then I need to also transfer... (4 Replies)
Discussion started by: cckaiser15
4 Replies

2. UNIX for Beginners Questions & Answers

Converting negative number to positive in a file

Hi ALL, I am having semi column separated file as below. I am having negative values for the records starting with 11095. How can I convert that positive number I tried this below seems not working sed 's/ \(*\)$/ -\1/;t;s/\(.*\)-/\1/ myfile myfile... (6 Replies)
Discussion started by: arunkumar_mca
6 Replies

3. Post Here to Contact Site Administrators and Moderators

Bits in Negative

Hi All, I have received a notification that I have posted a question double times. But I have not done all this intentionally. I have just joined this site and was not aware of the rules. Also I have my bits in negative. what does that mean. Thanks (1 Reply)
Discussion started by: Palak Sharma
1 Replies

4. Shell Programming and Scripting

Splitting a file based on positive and negative numbers

Dear All, I have to split a tab delimited file in two files based on the presence of a positive or negative in column number 9 , for example file: A 1 5 erg + 6766 0.9889 0.9817 9.01882 erg inside upstream B 1 8 erg2 + 6766 0.9889 0.9817 -9.22 erg2 inside... (3 Replies)
Discussion started by: paolo.kunder
3 Replies

5. Shell Programming and Scripting

change value to negative

How to change value in column 5 to negative based on value in column 2 ? Example: For all records with A in column 2 change value in column 5 to negative. file Code: 1234~A~b~c~10~e~f~g~h~09/10/09 1234~A~b~c~75~e~f~g~h~11/12/10 1234~A~b~c~40~e~f~g~h~12/06/10 5678~B~b~c~2~e~f~g~h~01/11/11... (4 Replies)
Discussion started by: sigh2010
4 Replies

6. Shell Programming and Scripting

replace space with + and - as negative only

I have a file file1.dat with the following lines 22885068900000652 B86860003OLFXXX592123320081227 22885068900000652 B86860003ODL-Sp592123420081227 22885068900000652-B94030001ODL-Ch592123520081227 23666483030000653-B94030001ODL-Ch000000120081227 23797049900000654-E71060001OLFXXX000000220081227... (3 Replies)
Discussion started by: kshuser
3 Replies

7. Shell Programming and Scripting

find negative search

I have a config file as below. This file is delimited by ; First field is the starting directory for find command. Second field is -mtime value for the find command. Third field is combination of folder and file delimited by | /home/export/temp;+30;file1|dir1|file2... (3 Replies)
Discussion started by: cmoulee
3 Replies

8. Programming

Negative Offset

Function: int fcntl(int fd, int cmd, struct flock * lock) Data Type: struct flock This structure is used with the fcntl function to describe a file lock. It has these members: off_t l_start This specifies the offset of the start of the region to which the lock applies, and... (1 Reply)
Discussion started by: DNAx86
1 Replies

9. UNIX for Dummies Questions & Answers

negative permissions

Hi. I want to know how can I negate a write permission for a file to an expecific user when that user have that permission becouse he belongs to a group what have a write permission for the file. (4 Replies)
Discussion started by: sickoboy
4 Replies
Login or Register to Ask a Question