LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-17-2013, 02:13 PM   #1
linuxguy08
Member
 
Registered: Apr 2008
Posts: 155
Blog Entries: 2

Rep: Reputation: 15
find files not modified since 1 year and 6 months


Hi ,

I want to find files that are not modified since 1 year and 6 months.
could any one give the command as to how to find out?. I try some of the find options but that doesnot give me the answer for my requirement exactly.

Thanks
 
Old 07-17-2013, 02:15 PM   #2
bmrtin
LQ Newbie
 
Registered: Jan 2004
Location: georga
Distribution: fendora
Posts: 11

Rep: Reputation: 4
find <dir> -mtime +##

1.6 years * 365 = 534

find ./ -mtime +534
 
Old 07-17-2013, 02:33 PM   #3
linuxguy08
Member
 
Registered: Apr 2008
Posts: 155

Original Poster
Blog Entries: 2

Rep: Reputation: 15
Thanks for the quick response!!


if i want to estimate the size of that . is this a command ?


find ./ -mtime +534 | du -sh .

Thanks
 
Old 07-17-2013, 02:39 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
you will want something like:

Code:
find ./ -mtime +534 -print0 | du -ch
which doesnt work in ubuntu.

edit: out of curiosity, i was able to search and find this for ubuntu:

Code:
find . -printf "%s\n" | awk '{t+=$1}END{print t}'

Last edited by szboardstretcher; 07-17-2013 at 02:41 PM.
 
Old 07-17-2013, 02:48 PM   #5
bmrtin
LQ Newbie
 
Registered: Jan 2004
Location: georga
Distribution: fendora
Posts: 11

Rep: Reputation: 4
If you did that you would have to then add all the sizes together to get a grand total. ((< not aimed at szboardstretcher. His answer is also correct)) Here is a way using awk:

find . -mtime +534 -ls |awk '{total += $7} END {print total}'
This gives the result in bytes
For KB use:
find . -mtime +534 -ls |awk '{total += $7} END {print total/1024}'
For MB use:
find . -mtime +534 -ls |awk '{total += $7} END {print total/1024/1024}'
And so on...

Last edited by bmrtin; 07-17-2013 at 02:50 PM.
 
1 members found this post helpful.
Old 07-17-2013, 02:49 PM   #6
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Quote:
Originally Posted by szboardstretcher View Post
you will want something like:

Code:
find ./ -mtime +534 -print0 | du -ch
which doesnt work in ubuntu.

edit: out of curiosity, i was able to search and find this for ubuntu:

Code:
find . -printf "%s\n" | awk '{t+=$1}END{print t}'

Code:
du -hcs $(find ./ -mtime +534)
or

Code:
find ./ -mtime +534 -exec du -hcs {} +

Last edited by Firerat; 07-17-2013 at 02:51 PM.
 
Old 07-17-2013, 02:54 PM   #7
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Quote:
Originally Posted by bmrtin View Post
If you did that you would have to then add all the sizes together to get a grand total. ((< not aimed at szboardstretcher. His answer is also correct)) Here is a way using awk:

find . -mtime +534 -ls |awk '{total += $7} END {print total}'
This gives the result in bytes
For KB use:
find . -mtime +534 -ls |awk '{total += $7} END {print total/1024}'
For MB use:
find . -mtime +534 -ls |awk '{total += $7} END {print total/1024/1024}'
And so on...
Correct. I didnt mention that the first example will give the size of each file, and the second will add up all the files as bmrtin suggests here.
 
Old 07-22-2013, 02:29 PM   #8
linuxguy08
Member
 
Registered: Apr 2008
Posts: 155

Original Poster
Blog Entries: 2

Rep: Reputation: 15
Thanks for reply!!

I ran the following command to find files that are not modified since 1 year and 6 months

find . -mtime +534 -ls |awk '{total += $7} END {print total/1024/1024}'

and got the following output

2.37775e+06

Is it 2.3 TB size?

Thanks
 
  


Reply



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
Find modified files with special characters blaise77 Linux - Newbie 3 12-12-2012 05:35 AM
find files that has modified eprait01 Programming 5 02-05-2012 10:00 AM
Find all files created or modified between 2 times MicahCarrick Linux - Software 3 06-29-2006 04:22 PM
FIND files modified 1 hour before sachinh Linux - General 3 05-20-2006 04:42 AM
find today's modified files cranium2004 Linux - General 2 03-08-2006 09:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:05 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
Open Source Consulting | Domain Registration