LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-25-2014, 04:11 PM   #1
Calab
Member
 
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 32

Rep: Reputation: 0
Question How to list only files, sorted by date?


I am writing a bash script and I need to collect a list of files in the current directory, sorted by the date that the files were modified (or created).

I know that "ls -t" will sort by date.

I know that "find -type f" will only show files.

I don't know how I can do both at once.
 
Old 03-25-2014, 04:28 PM   #2
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,117
Blog Entries: 2

Rep: Reputation: 113Reputation: 113
ls -t --file-type | grep -v '/'

Last edited by estabroo; 03-25-2014 at 05:17 PM. Reason: switched ls option
 
Old 03-25-2014, 06:56 PM   #3
Calab
Member
 
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 32

Original Poster
Rep: Reputation: 0
Smile

Quote:
Originally Posted by estabroo View Post
ls -tF | grep -v '/'
This is working well.

I was afraid that this would leave the extra characters on the files as well, but I'm finding that this isn't the case.

...and I see that you updated your answer. I'll see if it makes a difference to my application.

Thanks!

Last edited by Calab; 03-25-2014 at 06:59 PM.
 
  


Reply

Tags
date, directories, files, sort


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] List all regular files in the disk sorted by modification time. stf92 Slackware 4 11-06-2013 09:43 AM
How to display all rpm installed list sorted by date yzhang738@hotmail.com Linux - Newbie 3 10-05-2010 12:44 AM
[SOLVED] looking for a way to list files sorted by size mark_alfred Linux - General 4 08-22-2009 10:20 AM
concatenate files sorted by date docaia Programming 5 08-16-2008 09:32 PM
How do I produce sorted list of files in current directory over a certain size? bangback Linux - Newbie 3 10-25-2006 01:11 AM


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