Sponsored Content
Top Forums Shell Programming and Scripting How to traverse directory structure and sum size of files? Post 302432442 by zaxxon on Friday 25th of June 2010 05:15:06 AM
Old 06-25-2010
Half a million files can take their time. Add a -print in front of your -exec to see if it's stuck.

---------- Post updated at 11:15 AM ---------- Previous update was at 09:54 AM ----------

You should also use the -mtime option instead of -atime since -atime timestamp will be updated even if you had just a reading action on the file. -mtime resembles to the date you see when you do a ls -l.
To express a "starting" and "ending" time you can also combine 2 -mtime like:
Code:
find . -mtime -730 -mtime +365 -print -exec rm '{}' \;

which should delete all files older than 1 year but not older than 2 years ie. the year before the last year.
When experimenting with this, leave out the -exec rm so you do not accidentally delete things if something is not according to your needs.

Last edited by zaxxon; 06-25-2010 at 06:15 AM.. Reason: added info
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

MV files from one directory structure(multiple level) to other directory structure

Hi, I am trying to write a script that will move all the files from source directory structure(multiple levels might exist) to destination directory structure. If a sub folder is source doesnot exist in destination then I have to skip and goto next level. I also need to delete the files in... (4 Replies)
Discussion started by: srmadab
4 Replies

2. UNIX for Dummies Questions & Answers

copy files with directory structure

i have a text file as. /database/sp/NTR_Update_Imsi_List.sql /database/sp/NTR_Update_Imsi_Range_List.sql /database/sp/NTR_Vlr_Upload.sql /database/tables/StatsTables.sql /mib/ntr.mib /mib/ntr.v2.mib /scripts/operations/ntr/IMSITracer.ph /scripts/operations/ntr/IMSITracer.pl ... (3 Replies)
Discussion started by: adddy
3 Replies

3. Shell Programming and Scripting

find size, cp breaks directory structure

I'm using this now: find /some/path/with/sourcefiles -type f -size -7M -exec /bin/cp -uv {} /some/path/ \; but it doesn't preserve the directory structure, also I've tried it with find /some/path/with/sourcefiles -type f -size -7M -exec /usr/bin/rsync -auv {} /some/path/ \; but that doesn't... (9 Replies)
Discussion started by: unclecameron
9 Replies

4. Shell Programming and Scripting

Sum up files whose size Kbytes and Mbytes

Hello Friends, When i type du -sh *.jar | sort -n under a library directory i get a result similar below output: 1M 1.jar 2.4M 2.jar 4.5M 3.jar . . . . . . 1K (n-2).jar 15K (n-1).jar 77.7K n.jar I want to sum up the size... (1 Reply)
Discussion started by: EAGL€
1 Replies

5. Shell Programming and Scripting

Sum of file size in directory / subdirectory

Hi , I am trying to write something to find the size of particular type of files in a directory & it's subdirectory and sum the size .. These types of file are found at directory level or its subdirectories level .. #!/bin/ksh FNAME='.pdf' S_PATH=/abc/def/xyz find $S_PATH -exec ls -lad... (4 Replies)
Discussion started by: Vaddadi
4 Replies

6. Shell Programming and Scripting

Traverse file structure from top and rename the immediate parent

Hello All, I am trying to write a script to:- 1. Traverse entire file system, look for directories which has .git directory in it 2. Rename the immediate parent directory to <orignal_name.git> 3. Traverse new file structure and look for all directories with <original_name>.git 4. cd to... (2 Replies)
Discussion started by: sahil_jammu
2 Replies

7. UNIX for Dummies Questions & Answers

How to get the set of files size as a sum in a directory.

Hi, Can someone help me to get the complete files size (sum) over a perod time (1 day,2days)in a directory. eg: Directory :ABC I have a1,a2,a3 files are created in last 24 hours so I need to get the some of all these files. I am using the below find command but its giving me the... (1 Reply)
Discussion started by: gaddamja
1 Replies

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

9. Shell Programming and Scripting

Archiving files keeping the same structure directory

Hello Team, We would like to backup a lot of files inside of a structure of directories, four, five or more levels in some Ubuntu, Mac and Solaris systems. For instance: /home/chuck/sales/virgin/rent-quote.pdf /home/chuck/sales/marriott/vacation-quote.pdf... (2 Replies)
Discussion started by: csierra
2 Replies
MARIA-CSO(1)						      General Commands Manual						      MARIA-CSO(1)

NAME
maria-cso - shared library generator for maria SYNOPSIS
maria-cso directory library.so file.c... maria-cso directory library.so file.c DESCRIPTION
This manual page documents briefly the maria-cso command. maria-cso is a shell script invoked by maria in order to compile generated C code into dynamically loadable shared object files. The script invokes the C compiler and the linker, and it calculates checksums in order to avoid compiling unmodified modules. The directory argument specifies the location of the source files. When the script is invoked with one file.c argument, it translates the file to the shared object library.so. When maria-cso is invoked with multiple file.c arguments, it computes a checksum of a file named multiset.h and of each argument. When the header file multiset.h has been changed since the previous invocation of maria-cso, everything will be recompiled. Otherwise only those file.c modules that have been modified will be recompiled. The checksum files are multiset.sum and c.sum. SEE ALSO
maria(1), sh(1). ENVIRONMENT VARIABLES
CC Name of the C compiler CFLAGS Command-line switches to be passed to the C compiler DEFINES Preprocessor macro definitions to be passed to the C compiler FILES
/usr/share/maria/runtime/*.h Header files for the run-time library AUTHOR
This manual page was written by Marko Makela <msmakela@tcs.hut.fi>. The maria-cso script and the compilation option were designed and implemented by Marko Makela. Please see the copyright file in /usr/share/doc/maria for details. August 10, 2001 MARIA-CSO(1)
All times are GMT -4. The time now is 03:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy