LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-25-2012, 01:10 AM   #1
Vthimmap
Member
 
Registered: Oct 2012
Posts: 36

Rep: Reputation: Disabled
File size comparsion


A file gets generated everyday in the directory (date wise: 01 02 03 etc upto 31)
ex:2012/01/prices.gz
2012/02/prices.gz
2012/03/prices.gz

Need to compare the filesize with respect to previous days
 
Old 10-25-2012, 01:31 AM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
It can be done using du command,
Code:
do -sh 2012/01/prices.gz
And
du -sh 2012/02/prices.gz
Or create a simple script:
Code:
#!/bin/bash
echo -n "Enter filename1: "
read filename1
echo -n "Enter filename2: "
read filename2
s1=$(du -sh $filename1)
s2=$(du -sh $filename2)
echo "$s1"
echo "$s2"

Last edited by shivaa; 10-25-2012 at 01:53 AM.
 
Old 10-25-2012, 01:31 AM   #3
nugat
Member
 
Registered: Sep 2012
Posts: 122

Rep: Reputation: 31
Quote:
Originally Posted by Vthimmap View Post
Need to compare the filesize with respect to previous days
Can you be more specific? Do you mean that you just need to print out the file sizes of all files in a given year directory? If so, you can do something like:

Code:
find . -type f -printf "%p " -exec stat -c %s {} \;
if you literally want to compare two file sizes, then you'll need to do some sort of bash for/while loop.

Last edited by nugat; 10-25-2012 at 01:32 AM. Reason: typo
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Store the size of largest file from a file/directory listing into variable SIZE lainey Linux - Newbie 3 11-15-2011 01:29 PM
any ideas to reduce log file size or make log file size managed? George2 Programming 2 08-13-2006 07:55 AM
Open/Net/FreeBSD Comparsion kaon *BSD 3 02-08-2005 12:19 PM
good sequence comparsion algorithm? feetyouwell Programming 2 10-14-2004 06:58 AM
Is there any comparsion chart available for graphic cards? lamiczka Linux - Hardware 1 02-17-2004 12:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration