Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-25-2014, 03:11 PM   #1
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, 03:28 PM   #2
Senior Member
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,125
Blog Entries: 2

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

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

Original Poster
Rep: Reputation: 0

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.


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


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 08:43 AM
How to display all rpm installed list sorted by date Linux - Newbie 3 10-04-2010 11:44 PM
[SOLVED] looking for a way to list files sorted by size mark_alfred Linux - General 4 08-22-2009 09:20 AM
concatenate files sorted by date docaia Programming 5 08-16-2008 08:32 PM
How do I produce sorted list of files in current directory over a certain size? bangback Linux - Newbie 3 10-25-2006 12:11 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:27 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration