LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 01: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, 01:21 PM   #2
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 snorky View Post
In BASH how do I list all files older than 1000 days?
Code:
find / -mtime +1000
 
Old 05-13-2011, 01: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: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
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, 01:24 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
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, 01: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: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
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, 03: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, 03: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: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
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, 03:58 PM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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



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

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

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