get file size by date for a directory

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting get file size by date for a directory
# 1  
Old 09-15-2009
get file size by date for a directory

Good day

Probably a simple script though I am new to attempting to script. I have a directory that I would like to get the size of the files and number of files for each date

ie 14 Sep 669 files 1.8g
12 Sep 221 files 500mb

Any ideas?

# 2  
Old 09-15-2009
Generally speaking, you can take the output of an:

ls -ltr /your/path

and parse that in perl or awk. You can use shell scripting too, but for me personally, I would use perl to create a record with hash variables that will track the file count and the cumulative size of all files for each date.

The '-r' option on the ls command is optional, it just reverses the sense of the listing, so you get oldest files at the top of the listing and the newest files at the bottom. Otherwise you'll get newest at the top and oldest at the bottom.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Size of a directory or a file

Hello, Here is my code: :~$ truncate -s 16M MyTestFile.txt :~$ du -h MyTestFile.txt 4,0K MyTestFile.txt Q1: Please why du -h does not work in this case ? Q2: Other than "du -h", how can i get the size of a directory (using linux command) Thanks a lot. Best Regards. (2 Replies)
Discussion started by: chercheur111
2 Replies

2. Shell Programming and Scripting

Script to determine Date,TotalFile,total size of file based on date

I have file listed like below -rw-r--r--+ 1 test test 17M Nov 26 14:43 test1.gz -rw-r--r--+ 1 test test 0 Nov 26 14:44 test2.gz -rw-r--r--+ 1 test test 0 Nov 27 10:41 test3.gz -rw-r--r--+ 1 test test 244K Nov 27 10:41 test4.gz -rw-r--r--+ 1 test test 17M Nov 27 10:41 test5.gz I... (5 Replies)
Discussion started by: krish2014
5 Replies

3. UNIX for Dummies Questions & Answers

Ls directory size reporting byte size instead of file count

I have been searching both on and Google and have not been able to find the answer to my question. I think it is partly because I can't come up with the right search terms. Recently, my virtual server switched storage devices and I think the problem may be related to that change.... (2 Replies)
Discussion started by: jmgibby
2 Replies

4. Shell Programming and Scripting

How to delete some of the files in the directory, if the directory size limits the specified size

To find the whole size of a particular directory i use "du -sk /dirname".. but after finding the direcory's size how do i make conditions like if the size of the dir is more than 1 GB i hav to delete some of the files inside the dir (0 Replies)
Discussion started by: shaal89
0 Replies

5. Solaris

Directory size larger than file system size?

Hi, We currently have an Oracle database running and it is creating lots of processes in the /proc directory that are 1000M in size. The size of the /proc directory is now reading 26T. How can this be if the root file system is only 13GB? I have seen this before we an Oracle temp file... (6 Replies)
Discussion started by: sparcman
6 Replies

6. Shell Programming and Scripting

Size of file and directory

Hello. I do have a problem. The statement sounds like this: Given a directory, find all subdirectories (regardless of depth) which contain a file that has more than a half of the size of the respective subdirectory. I've tried to solve this in many ways, but all I came up with is half... (1 Reply)
Discussion started by: WorkOfArt
1 Replies

7. Shell Programming and Scripting

How to compare size of two file which is in one directory

I have two file in a Directory.I want a script which will compare the Size of Two file. Can Anyone Help me on this: linasplg11:/opt/dataout/kk/linasplg11 # cat size -rwxrwxrwx 1 root root 16658 Jan 8 13:58 lina_IP_SIP_1231325621210.xml -rwxr-xr-x 1 root root 16672 Jan 8 14:30... (1 Reply)
Discussion started by: Aditya.Gurgaon
1 Replies

8. Shell Programming and Scripting

How to know size of file in a directory

Hi, I have to directory /usr/inbound ------------- 10900.txt 10889.txt 109290202.txt I need to create inbound directory and i need to know size of these files one by one if file size is zero i need to print message like "empty file" Please help me how to solve this thanks krish. (1 Reply)
Discussion started by: kittusri9
1 Replies

9. UNIX for Advanced & Expert Users

Find file size and date

Hi in my shell script I have to do this 1. there is a file called testing.txt in /home/report directory If the file size is 0(zero) and date is today's date, then I have to print "Successful" else "Failed". 2. There is a file called number.txt which will have text only one line like this... (10 Replies)
Discussion started by: gsusarla
10 Replies

10. Filesystems, Disks and Memory

Delete file by date or by size

Hi Everyone, This forum has been a great help to me as a new newbie in Unix. Thanks to you all. My ? now is I have a log file that help me keep track of errors within my program. But the size of the log file keeps growing and I am wondering if there is any command that will help me to... (1 Reply)
Discussion started by: odogbolu98
1 Replies
Login or Register to Ask a Question