LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-15-2009, 02:47 AM   #1
shad.ithbti
LQ Newbie
 
Registered: Aug 2009
Posts: 4

Rep: Reputation: 0
Lightbulb will it be poosile to sort the output of ls command based on timestamp of files.


Hello All,

Problem, i have some files under a directory say /home/user.

i want to pick up the file which has the latest timestamp.

for eg:
content of the directory is something like this
-rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.daily_sol
-rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.daily_linux
-rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.daily_hpux
-rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.daily_hpia64
-rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.daily_aix
-rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.7_linux
-rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.7_hpux
-rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.7_hpia64
-rw-r--r-- 1 root other 0 Sep 15 11:27 3.5.0.13.0.7_aix
-rw-r--r-- 1 root other 0 Sep 15 11:30 3.5.0.13.0.7_sol

my requirement here is when i give command
ls -lrt 3.5.0*_sol, it will return

-rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.daily_sol
-rw-r--r-- 1 root other 0 Sep 15 11:30 3.5.0.13.0.7_sol

from this output i want to pickup the file which is latest in term of date or time. in this case this is the one 11:30 3.5.0.13.0.7_sol

is there any option in ls command itself only to list based on timestamp.

Thanks,
Shadman
 
Old 09-15-2009, 02:51 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
see the -t switch;
ls -lt ( to see fname & other items)
ls -t (just filename)
http://linux.die.net/man/1/ls
 
  


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
Sort files in directories based on the files date... CharlieMike73 Programming 5 09-09-2009 11:04 PM
find all files in current folder and all subfolders and sort all by timestamp dlnlinux Linux - Newbie 2 06-03-2008 12:29 PM
command to sort by floats in fourth column of standard output jhwilliams Linux - Software 4 06-22-2007 02:27 PM
A command or script to rm files based on df output? Anithen Slackware 7 06-21-2007 11:18 PM
script to sort files according to timestamp aeby Linux - Newbie 1 05-16-2007 09:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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