Comparing sizes in percentages of 2 files in bash


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Comparing sizes in percentages of 2 files in bash
# 1  
Old 04-26-2011
Comparing sizes in percentages of 2 files in bash

Hi guys, I hope you can enlight me with a script I'm doing for Solaris 10.
Script goes like this:

Code:
#!/usr/bin/bash
fechahoy=`perl /export/home/info/John/fechamod.pl`
fechayer=`perl /export/home/info/John/fecha.pl`

echo $fechahoy
echo $fechayer
DAT1=`ssh ivt@blahblah ls -la /export/home/ivt/inventory/Services_$fechahoy* | awk -F" " {'print $5'}`
DAT2=`ssh ivt@blahblah ls -la /export/home/ivt/inventory/Services_$fechayer* | awk -F" " {'print $5'}`

Script uses another perl script who outputs date as YYYYMMDDHHMMSS (ex. 20110425151745)
Well, then I put ls -la to calculate the size of yesterday's file, and today's file.

Problem is I don't know how to compare the size of yesterday's file ($fechayer) to today's file ($fechahoy) and then, if the difference of the size is 20% less than yesterday, abort script with error.

What would be the algorithm for calculating that difference of size in percentage?

if fechahoy<fechayer by more than 20% --->then abort


Hope you help me, thanks a lot!

---------- Post updated at 02:20 PM ---------- Previous update was at 01:22 PM ----------

I've solved it, thanks.

Last edited by sr00t; 04-26-2011 at 03:36 PM..
# 2  
Old 04-26-2011
if (( ( ( $DAT2 * 100 ) / $DAT1 ) > 120 ))

or, share your solution!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing file sizes

Hello, I need to compare the size of a file to what it's size was 20min ago. So far my outline script is:ls -ls /home > filesizeafter.txt compare filesizeafter.txt filesizebefore.txt > filesizechange.txt if /home filesizechange.txt > 100 { email root; } ls -ls /home >... (2 Replies)
Discussion started by: chyurdan
2 Replies

2. Shell Programming and Scripting

To merge different sizes txt files

Hi, I have to .txt files that look like "baseMean" "log2FoldChange" "lfcSE" "stat" "pvalue" "padj" "c104215_g2_i4" 202.057864855455 5.74047973414006 1.14052672909697 5.03318299141063 4.8240223910525e-07 0.00234905721174879 "c91544_g1_i1" 373.123487095726 5.62496675850204 1.15060014539303... (2 Replies)
Discussion started by: alisrpp
2 Replies

3. Homework & Coursework Questions

Bash script for printing folder names and their sizes

1. The problem statement, all variables and given/known data: The task is to create a script that would reproduce the output of 'du' command, but in a different way: what 'du' does is: <size> <folder name>and what is needed is <folder name> <size>We need to show only 10 folders which are the... (3 Replies)
Discussion started by: UncleIS
3 Replies

4. Shell Programming and Scripting

Bash script for printing folder names and their sizes

Good day, everyone! I'm very new to bash scripting. Our teacher gave us a task to create a script that basically does the same job the 'du' command does, with the difference that 'du' command gives an output in the form of <size> <folder name>and what we need is <folder name> <size>As for... (1 Reply)
Discussion started by: UncleIS
1 Replies

5. Shell Programming and Scripting

Listing Files and Sizes on FTP server

Need assistance in getting File size for the List of files using perl script . I have writtern 2 codes. One of them gives me the list of files and 2nd one give me the size for only 1 file. I dont know how to club both of them to get the list of files with its size . #!/usr/bin/perl -w... (11 Replies)
Discussion started by: ajayram_arya
11 Replies

6. Shell Programming and Scripting

Need Help with Bash - comparing directory contents with list of files

Hey guys, need help with a script I'm trying to write. Basically I need to compare the contents of a folder called "profiles" with a list of files called "template". when the file matches the contents of the folder it needs to set a variable called "checked" to "1" Cookies to anyone... (4 Replies)
Discussion started by: Scriporium
4 Replies

7. Programming

Checking columns in SQL, comparing user input and sizes.

I'm writing a KSH shell script that's using SQL though DB2. If I have a table defined and populated db2 "create table tb(num int,letter char(4))" db2 "insert into tb values(111,a) db2 "insert into tb values(112,b) db2 "insert into tb values(111,c) How can I check if a letter user... (0 Replies)
Discussion started by: busdude
0 Replies

8. Shell Programming and Scripting

Search directories for files with zero sizes to delete

Hi, I am trying to write a script that will use ls on a directory and list the files one at a time and their size. If the size is 0 i want it to ask me if I want to delete it (yes or no). If I say yes, I want it to delete but it won't know what the file name is just from running from the script.... (2 Replies)
Discussion started by: akeenabawa
2 Replies

9. Shell Programming and Scripting

Join - files of different sizes

I am trying to join to files with dramatically different sizes (file 1: 1 column - 9000 rows, file 2: 13 cols, 26 million rows). I can't seem to get join to work. I have check to ensure that there are matches and have tried subsamples that work. The -a filenum flag lists all the rows, so join is... (4 Replies)
Discussion started by: annelie
4 Replies

10. Shell Programming and Scripting

Sum of Files Sizes starting with a letter...

Can we find some of size of all files in a directry where file names start with an letter t* the out put of ls -ls t* is 4 -rw-r--r-- 1 root system 61 Jul 03 10:56 t 4 -rw-r--r-- 1 root system 3146 Jul 19 11:11 t1 4 -rw-r--r-- 1 root system ... (2 Replies)
Discussion started by: pbsrinivas
2 Replies
Login or Register to Ask a Question