How can I find the size of files added to a folder after a particular date


 
Thread Tools Search this Thread
Operating Systems HP-UX How can I find the size of files added to a folder after a particular date
# 1  
Old 10-27-2010
How can I find the size of files added to a folder after a particular date

Hi,
I want to find the size of the files added to a folder after a certain date(say 1st of october), I know we can list the files which were created after a certain date , but is there anyway to find the total size of those files ?
# 2  
Old 10-27-2010
Not exactly. Inodes have three dates, and of course both files and directories are inodes. Seem man stat:
Code:
           time_t   st_atime;     /* Time of last access */
           time_t   st_mtime;     /* Last modification time */
           time_t   st_ctime;     /* Last file status change time */
                                  /* Measured in secs since */
                                  /* 00:00:00 GMT, Jan 1, 1970 */

However, all a directory holds is pairs of entry name strings and binary inode numbers. This is why hard links must be on the same device. In some respects, it is sadly plain, but simple.

If the file was modified or status'd at the time it was linked into the directory, you can use those times. The directory times are for the last file added or removed, which includes renames (mv), as that is done by adding a hard link (another directory entry for the same inode) and then deleting the original directory entry (ln a b;rm a).
# 3  
Old 10-27-2010
Maybe you're looking for something like this.

The output of ls -l are different in some versions but you can give this a try:
Code:
ls -l | awk '!/^d/ && /2010-10-01/{s+=$5}END{print s}'

# 4  
Old 10-27-2010
If you want to segregate files by the file times as shown in man stat, you can use 'find'. There are two flavors there.
  • The mtime/time/atime arguments are real time clock sensitive and day-granular, but fine for gross bracketing. You can say
    Code:
    -ctime +3 -ctime -5

    to get 2 days 3-d days ago to the second.
  • The newer works with the modification time and a marker file per -newer, so you can say
    Code:
    -newer a ! -newer b

    to get files in any exact range in seconds. See man touch for creating and resetting the mtimes of files.

I was at a loss for better tools to access stat() data, so I wrote one, but the latest version, with arguments for every stat element, seems to be hiding. It can take in a stream of file names and spits them out annotated with the UNIX mtime, in integer seconds since 1970 started, GMT:
Code:
$ cat mysrc/mystat.c

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>

static void psf( char * buf )
{
        struct stat s ;

        if ( 0 > stat( buf, &s ) )
        {
                perror( buf );
                return ; ;
        }

        if ( 0 > printf( "%u\t%s\n", s.st_mtime, buf ) )
        {
                if ( !ferror( stdout ) )
                        exit( 0 );
                perror( "stdout" );
                exit( 1 );
        }
}

int main( int argc, char **argv )
{
        char buf[PATH_MAX + 2];
        char *cp ;
        int i ;
        int clf = 0 ;

        for ( i = 1 ; i < argc ; i++ )
        {
                clf ++ ;
                psf( argv[i] );
        }

        if ( !clf ) while ( fgets( buf, sizeof buf, stdin ) )
        {
                if ( !( cp = strchr( buf, '\n' ) ) )
                {
                        fprintf( stderr, "File path too long: '%s'\n", buf );
                        continue ;
                }

                *cp = NULL ;
                psf( buf );
        }

        if ( !ferror( stdin ) )
                exit( 0 );

        perror( "stdin" );
        exit( 1 );
}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

UNIX script to replace old date with current date dynamically in multiple files present in a folder

I am trying to work on a script where it is a *(star) delimited file has a multiple lines starts with RTG and 3rd column=TD8 I want to substring the date part and I want to replace with currentdate minus 15 days. Here is an example. iam using AIX server $ cat temp.txt RTG*888*TD8*20180201~... (1 Reply)
Discussion started by: Shankar455
1 Replies

2. Shell Programming and Scripting

Find latest date in folder

HI I have folder in home dir. /home/kpp/07222013 /home/kpp/07212013 /home/kpp/07202013 Output :-- /home/kpp/07222013 Just find latest date (5 Replies)
Discussion started by: pareshkp
5 Replies

3. HP-UX

find command to display size and date of a file

Hi, The blow code does not yeild any output. find . -name "*.jar" -o -name "*.ksh" -o -name "*.properties" -name "*.war" -o -name "*.ear" -o -name "*.sh" -o -name "*.cfg" -exec ls -l {} \; I wish to print the filename filesize filedate in HP-UX. Can anyone help ? (9 Replies)
Discussion started by: mohtashims
9 Replies

4. Shell Programming and Scripting

How to find last updated date and time of a folder in Perl?

Hi All, I have a process which after some time continues move a files to some folder(say the name of the folder is logdir) What i am trying to do is as the files are coming to the logdir folder, I want the latest updated time and date of the folder in PERL. (1 Reply)
Discussion started by: parthmittal2007
1 Replies

5. Shell Programming and Scripting

Find all text files in folder and then copy to a new folder

Hi all, *I use Uwin and Cygwin emulator. I´m trying to search for all text files in the current folder (C/Files) and its sub folders using find -depth -name "*.txt" The above command worked for me, but now I would like to copy all found text files to a new folder (C/Files/Text) with ... (4 Replies)
Discussion started by: cgkmal
4 Replies

6. UNIX for Dummies Questions & Answers

how to find folder size with created date

hi, please give me adivse .how to find the folder size with created created date . eg: i have directore and in that sub directoties and so on.. /home/mud/abc/dcb/ for this i want output like this path size date -------------------------------------------... (3 Replies)
Discussion started by: muddasani
3 Replies

7. 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

8. UNIX for Dummies Questions & Answers

How can I find files by date or size from stout?

Hello all I wander if I make for example " ls -l " And it gives me all the files in the directory with the additional info like data size and privileges But what if I like to filter the stout result for example by date When I try to do: echo "`ls -l`" | grep "Jan 12" it gives me the... (2 Replies)
Discussion started by: umen
2 Replies

9. UNIX for Dummies Questions & Answers

shell script to find files by date and size

Hi, I have a directory PRIVATE in which I have several directories and each of these have several files. Therefore, I need to find those files by size and date to back up those files in another directory. I don't know how to implement this shell script using ''find''. appreciate any... (1 Reply)
Discussion started by: dadadc
1 Replies

10. Shell Programming and Scripting

Scripting to find the size of the folder

Will any body help me by writing a script in unix to the find out the size of the Main folder which has some 5 to 6 subfolders which in turn has some file in each of these subfolders regards victorvvk (2 Replies)
Discussion started by: victorvvk
2 Replies
Login or Register to Ask a Question