Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-25-2012, 12:10 AM   #1
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)

Need to compare the filesize with respect to previous days
Old 10-25-2012, 12:31 AM   #2
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,
do -sh 2012/01/prices.gz
du -sh 2012/02/prices.gz
Or create a simple script:
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 12:53 AM.
Old 10-25-2012, 12:31 AM   #3
Registered: Sep 2012
Posts: 122

Rep: Reputation: 31
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:

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 12:32 AM. Reason: typo


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 12:29 PM
any ideas to reduce log file size or make log file size managed? George2 Programming 2 08-13-2006 06:55 AM
Open/Net/FreeBSD Comparsion kaon *BSD 3 02-08-2005 11:19 AM
good sequence comparsion algorithm? feetyouwell Programming 2 10-14-2004 05:58 AM
Is there any comparsion chart available for graphic cards? lamiczka Linux - Hardware 1 02-17-2004 11:59 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:07 PM.

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