LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 05-13-2011, 02:19 PM   #1
snorky
LQ Newbie
 
Registered: Aug 2003
Location: upper left corner, US of A
Distribution: several
Posts: 15

Rep: Reputation: 1
BASH: filters for ls command


In BASH how do I list all files older than 1000 days?
 
Old 05-13-2011, 02:21 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,211

Rep: Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612
Quote:
Originally Posted by snorky View Post
In BASH how do I list all files older than 1000 days?
Code:
find / -mtime +1000
 
Old 05-13-2011, 02:22 PM   #3
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello,

Have a look at the man page for find, more in particular the -mtime and -atime parameters.
Code:
man find
Kind regards,

Eric
 
Old 05-13-2011, 02:24 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,211

Rep: Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612
Thumbs up

Quote:
Originally Posted by EricTRA View Post
Hello,

Have a look at the man page for find, more in particular the -mtime and -atime parameters.
Code:
man find
Kind regards,

Eric
One of the most confusing man pages ever. For me anyway. I really needed a chart and graph to grasp the -x, x and +x of mtime.
 
Old 05-13-2011, 02:26 PM   #5
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hi,

It is indeed pretty complex (but also complete) but after reading what you need like 4 times it becomes clear.

Kind regards,

Eric
 
Old 05-13-2011, 04:41 PM   #6
snorky
LQ Newbie
 
Registered: Aug 2003
Location: upper left corner, US of A
Distribution: several
Posts: 15

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by szboardstretcher View Post
Code:
find / -mtime +1000
The problem is that I need the kind of information that ls gives, e.g., date, owner.

Also, the find command chokes on some files (it stopped on a rather large .mov file
 
Old 05-13-2011, 04:56 PM   #7
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello,

Have a look at the man page for ls:
Code:
-c     with -lt: sort by, and show, ctime (time of  last  modification  of  file
             status  information) with -l: show ctime and sort by name otherwise: sort
             by ctime
That will sort your files by last modification time for example. From there you'd have to use some more scripting to calculate if the last modification time exceeds your limit of 1000 days.

Kind regards,

Eric
 
Old 05-13-2011, 04:58 PM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by snorky View Post
The problem is that I need the kind of information that ls gives, e.g., date, owner.

Also, the find command chokes on some files (it stopped on a rather large .mov file
Try this (it will fail if there are a very large number of files)
Code:
ls -l $( find / -mtime +1000 )
Are you sure about find choking? It is very robust.
 
  


Reply


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] How write a literal bash command in a bash file? xeon123 Linux - Newbie 6 11-29-2010 01:05 PM
Bash history delete command from bash itself ashishag Linux - Software 6 05-02-2010 04:39 AM
Bash Command Line Editor, while typing run another command before executing current? gumaheru Linux - General 5 04-13-2010 12:21 PM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 12:10 PM
Automatically append another piped command to issued command in bash amateen Programming 1 05-07-2009 07:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 09:42 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration