LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-12-2006, 02:59 PM   #1
chucker8
Member
 
Registered: Nov 2005
Posts: 52

Rep: Reputation: 15
linux newbie...Q: how to find files and sort by time


I want to search for all files on the system ending in .log, and have the results sorted by most recently modified

find / -name '*.log' | ?

thanks!
 
Old 05-12-2006, 03:55 PM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
Does the following work for you
Code:
ls -t `find / -name "*.log"`
Note I have to run it as root or I get a lot of errors about permission denied...
 
Old 05-12-2006, 04:06 PM   #3
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
On a side question, I just noticed my output shows different values for different files. Some logs have a time stamp of Month Day Time and others have a Month Day Year... Weird.

Does anyone know why some files are MDT and some are MDY? The break seems to be anything created before Dec 1, 2005 is Month Day Year and anything after Dec 1, 2005 is Month Day Time. I think I did a dist-upgrade from woody to sarge around that time...
 
Old 05-12-2006, 04:28 PM   #4
chucker8
Member
 
Registered: Nov 2005
Posts: 52

Original Poster
Rep: Reputation: 15
yeah, that works for me:

find / -name '*.log'

But, the results are not sorted by most recently modified. I'm troubleshooting WebLogic 8.1, so I want to see what log files the server is writing to.

thanks
 
Old 05-12-2006, 04:37 PM   #5
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
You missed the ls -t `find / -name "*.log"` part...
 
Old 05-12-2006, 04:58 PM   #6
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 34
Quote:
Originally Posted by pljvaldez
Some logs have a time stamp of Month Day Time and others have a Month Day Year... Weird.
Files will have Month-Day-Time until they are 6 months old, then it's just MDY. This is just a convention of ls, of course. I suppose the rationale is that when a file is old, you're not that bothered what time of day it was modified, and at some point, you want to know the year.
 
Old 05-12-2006, 05:01 PM   #7
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
Thanks ioerror, learn something new everyday!
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linux find to find files with multiple patterns subu_s Programming 6 12-15-2010 12:15 AM
sort of Newbie Ken Russell LinuxQuestions.org Member Intro 2 01-31-2006 03:18 PM
Help with some scripting to find and sort? thebudbottle Linux - General 3 03-21-2005 05:20 AM
Mandrake 10 - Find Files crashes every time? AngelicCharon Mandriva 2 05-22-2004 02:06 PM
Find files based on time. FinalFantasy Linux - Software 4 05-21-2004 07:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:43 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